-
-
Notifications
You must be signed in to change notification settings - Fork 34.6k
gh-141510, PEP 814: Add frozendict support to pickle #144967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
3eb714a
d7972ff
24d757a
416a1b7
9666d7e
2939cba
8162f6b
64cba52
90842c1
c5f7ef7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2839,11 +2839,13 @@ def test_recursive_multi(self): | |
| self.assertEqual(list(x[0].attr.keys()), [1]) | ||
| self.assertIs(x[0].attr[1], x) | ||
|
|
||
| def _test_recursive_collection_and_inst(self, factory, oldminproto=None): | ||
| def _test_recursive_collection_and_inst(self, factory, oldminproto=None, | ||
| minprotocol=0): | ||
| if self.py_version < (3, 0): | ||
| self.skipTest('"classic" classes are not interoperable with Python 2') | ||
| # Mutable object containing a collection containing the original | ||
| # object. | ||
| protocols = range(minprotocol, pickle.HIGHEST_PROTOCOL + 1) | ||
| o = Object() | ||
| o.attr = factory([o]) | ||
| t = type(o.attr) | ||
|
|
@@ -2883,6 +2885,9 @@ def test_recursive_tuple_and_inst(self): | |
| def test_recursive_dict_and_inst(self): | ||
| self._test_recursive_collection_and_inst(dict.fromkeys, oldminproto=0) | ||
|
|
||
| def test_recursive_frozendict_and_inst(self): | ||
|
vstinner marked this conversation as resolved.
|
||
| self._test_recursive_collection_and_inst(frozendict.fromkeys, minprotocol=2) | ||
|
|
||
| def test_recursive_set_and_inst(self): | ||
| self._test_recursive_collection_and_inst(set) | ||
|
|
||
|
|
@@ -3095,6 +3100,15 @@ def test_float_format(self): | |
| # 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): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would not be better to add this test in
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I moved this test to test_pickle.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Commit dd64e42, which adds frozendict support to the |
||
| for proto in range(2, pickle.HIGHEST_PROTOCOL + 1): | ||
| for fd in ( | ||
| frozendict(), | ||
| frozendict(x=1, y=2), | ||
| ): | ||
| p = self.dumps(fd, proto) | ||
| self.assert_is_copy(fd, self.loads(p)) | ||
|
|
||
| def test_reduce(self): | ||
| for proto in protocols: | ||
| with self.subTest(proto=proto): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.