Skip to content
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

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

Merged
merged 2 commits into from
Oct 21, 2024

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Oct 21, 2024

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.
Doc/library/functions.rst Outdated Show resolved Hide resolved
Doc/whatsnew/3.14.rst Outdated Show resolved Hide resolved
@@ -36,6 +36,11 @@ def pickle_union(obj):

pickle(type(int | str), pickle_union)

def pickle_super(obj):
Copy link
Member

Choose a reason for hiding this comment

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

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 serhiy-storchaka merged commit 5ca4e34 into python:main Oct 21, 2024
37 checks passed
@serhiy-storchaka serhiy-storchaka deleted the super-pickle branch October 21, 2024 18:31
@serhiy-storchaka
Copy link
Member Author

Thank you for your suggestions and review @JelleZijlstra.

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