mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-82951: Fix serializing by name in pickle protocols < 4 (GH-122149)
Serializing objects with complex __qualname__ (such as unbound methods and nested classes) by name no longer involves serializing parent objects by value in pickle protocols < 4.
This commit is contained in:
parent
ca0f7c447c
commit
dc07f65a53
4 changed files with 82 additions and 26 deletions
|
@ -2818,6 +2818,18 @@ class AbstractPickleTests:
|
|||
self.assertIs(unpickled, Recursive)
|
||||
del Recursive.mod # break reference loop
|
||||
|
||||
def test_recursive_nested_names2(self):
|
||||
global Recursive
|
||||
class Recursive:
|
||||
pass
|
||||
Recursive.ref = Recursive
|
||||
Recursive.__qualname__ = 'Recursive.ref'
|
||||
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
|
||||
with self.subTest(proto=proto):
|
||||
unpickled = self.loads(self.dumps(Recursive, proto))
|
||||
self.assertIs(unpickled, Recursive)
|
||||
del Recursive.ref # break reference loop
|
||||
|
||||
def test_py_methods(self):
|
||||
global PyMethodsTest
|
||||
class PyMethodsTest:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue