diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-07-25 08:45:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-25 08:45:19 (GMT) |
commit | dc07f65a53baf60d9857186294d3d7ba92d5606d (patch) | |
tree | ad5e883c9e083b1f6af015b1fb2829a04abfad96 /Lib/test/pickletester.py | |
parent | ca0f7c447c83503bd760dc2eb6d1ea4b3558f8e9 (diff) | |
download | cpython-dc07f65a53baf60d9857186294d3d7ba92d5606d.zip cpython-dc07f65a53baf60d9857186294d3d7ba92d5606d.tar.gz cpython-dc07f65a53baf60d9857186294d3d7ba92d5606d.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/pickletester.py')
-rw-r--r-- | Lib/test/pickletester.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index 9922591..1366322 100644 --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -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: |