diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-10-21 18:30:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-21 18:30:45 (GMT) |
commit | 5ca4e34bc1aab8321911aac6d5b2b9e75ff764d8 (patch) | |
tree | d4f4dc4e80de809d695247c749a3ac50340ef78e /Lib/copyreg.py | |
parent | de5a6c7c7d00ac37d66cba9849202b374e9cdfb7 (diff) | |
download | cpython-5ca4e34bc1aab8321911aac6d5b2b9e75ff764d8.zip cpython-5ca4e34bc1aab8321911aac6d5b2b9e75ff764d8.tar.gz cpython-5ca4e34bc1aab8321911aac6d5b2b9e75ff764d8.tar.bz2 |
gh-125767: Fix pickling and copying of super objects (GH-125781)
Previously, copying a super object returned a copy of the instance
invoking super(). Pickling a super object could pickle the instance
invoking super() or fail, depending on its type and protocol.
Now deep copying returns a new super object and pickling pickles the super
object. Shallow copying returns the same super object.
Diffstat (limited to 'Lib/copyreg.py')
-rw-r--r-- | Lib/copyreg.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/copyreg.py b/Lib/copyreg.py index 5783924..17c5dde 100644 --- a/Lib/copyreg.py +++ b/Lib/copyreg.py @@ -36,6 +36,11 @@ def pickle_union(obj): pickle(type(int | str), pickle_union) +def pickle_super(obj): + return super, (obj.__thisclass__, obj.__self__) + +pickle(super, pickle_super) + # Support for pickling new-style objects def _reconstructor(cls, base, state): |