| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Add frozendict.__getnewargs__() method.
| # make sure that floats are formatted locale independent with proto 0 | ||
| self.assertEqual(self.dumps(1.2, 0)[0:3], b'F1.') | ||
|
|
||
| def test_frozendict(self): |
There was a problem hiding this comment.
Would not be better to add this test in test_frozendict.py? Together with tests for copy() and deepcopy()?
Sorry, something went wrong.
There was a problem hiding this comment.
Ok, I moved this test to test_pickle.
Sorry, something went wrong.
There was a problem hiding this comment.
Together with tests for copy() and deepcopy()?
Commit dd64e42, which adds frozendict support to the copy module, added frozendict tests to test_copy.
Sorry, something went wrong.
|
@serhiy-storchaka: I addressed your review. Please review the updated PR. |
Sorry, something went wrong.
There was a problem hiding this comment.
What about frozendict views and iterators? Are they copyable/pickleable?
Are there tests for deepcopying?
I am surprised that there is no separate test_frozendict.py.
Sorry, something went wrong.
|
Oh, I don't think deepcopy of frozendict is correct. It does not work for recursive frozendict. |
Sorry, something went wrong.
|
I will try to update my PR later to address other comments.
keys, values and items views cannot be copied nor serialized by pickle. Ah, it seems like it's possible to serialize a frozendict iterator.
test_copy.test_deepcopy_frozendict() tests frozendict deepcopy.
Ah. It was simple to add frozendict tests to existing test_dict. Maybe we can create test_frozendict later once we will add more tests. |
Sorry, something went wrong.
You're right, the current copy.deepcopy() implementation doesn't work for recursive frozendict. |
Sorry, something went wrong.
|
I completed the PR to add requested tests. |
Sorry, something went wrong.
I created #145027 to fix copy.deepcopy() for recursive frozendict. |
Sorry, something went wrong.
| pickle.dumps(fd, proto) | ||
|
|
||
| def test_pickle_iter(self): | ||
| it = iter(frozendict(x=1, y=2)) |
There was a problem hiding this comment.
What about value iterator and item iterator?
Consume one item from the iterator, to ensure that it correctly restores its state. See pickling tests in test_ordered_dict for example.
If things are pickleable, they should also be deepcopyable. It is worth to have explicit deepcopy tests, because they can preserve additional invariants. For example, it should be possible to deepcopy a frozendict containing lambdas or modules.
Sorry, something went wrong.
I propose merging this PR first (once it will be approved), and then adding such tests to #145027 PR. |
Sorry, something went wrong.
|
Did you forget to push changes for comments which you marked resolved? |
Sorry, something went wrong.
Remove also DictKey (use Object instead).
|
Ooops, you're correct. I forgot to push my changes, but I also removed my local branch... I had to rewrite my changes. I just pushed them. I should be ok now. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM. 👍
Sorry, something went wrong.
|
Merged. Thanks for your great review @serhiy-storchaka, it was very useful! |
Sorry, something went wrong.
|
This broke Oddballs (i.e. text_xpickle): https://buildbot.python.org/#/builders/1868/builds/5 |
Sorry, something went wrong.
Oh, I'm not used to test_xpickle yet, I forgot about it. I wrote #145069 to fix test_xpickle. |
Sorry, something went wrong.
…4967) Add frozendict.__getnewargs__() method.
…4967) Add frozendict.__getnewargs__() method.
| Back | FazBrowse Home | New Git URL |
Add frozendict.__getnewargs__() method.