FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-125767: Fix pickling and copying of super objects by serhiy-storchaka · Pull Request #125781 · python/cpython · GitHub

/ cpython Public

gh-125767: Fix pickling and copying of super objects - #125781

Merged
serhiy-storchaka merged 2 commits into
python:mainfrom
serhiy-storchaka:super-pickle
Oct 21, 2024
Merged

gh-125767: Fix pickling and copying of super objects#125781
serhiy-storchaka merged 2 commits into
python:mainfrom
serhiy-storchaka:super-pickle

Conversation

serhiy-storchaka commented Oct 21, 2024
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Member

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.


📚 Documentation preview 📚: https://cpython-previews--125781.org.readthedocs.build/

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.
Comment thread Doc/library/functions.rst Outdated
Comment thread Doc/whatsnew/3.14.rst Outdated
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Comment thread Lib/copyreg.py

pickle(type(int | str), pickle_union)

def pickle_super(obj):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Should we give this a private name? All the existing ones also use public names, so I don't mind keeping this one public too.

serhiy-storchaka merged commit 5ca4e34 into python:main Oct 21, 2024
serhiy-storchaka deleted the super-pickle branch October 21, 2024 18:31

Copy link
Copy Markdown
Member Author

Thank you for your suggestions and review @JelleZijlstra.

ebonnal pushed a commit to ebonnal/cpython that referenced this pull request Jan 12, 2025
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL