[3.14] gh-135228: When @dataclass(slots=True) replaces a dataclass, make the original class collectible (take 2) (GH-137047)#137666
Merged
hugovk merged 1 commit intopython:3.14python/cpython:3.14from Aug 12, 2025
miss-islington:backport-6859b95-3.14miss-islington/cpython:backport-6859b95-3.14Copy head branch name to clipboard
Merged
[3.14] gh-135228: When @dataclass(slots=True) replaces a dataclass, make the original class collectible (take 2) (GH-137047)#137666hugovk merged 1 commit intopython:3.14python/cpython:3.14from miss-islington:backport-6859b95-3.14miss-islington/cpython:backport-6859b95-3.14Copy head branch name to clipboard
hugovk merged 1 commit intopython:3.14python/cpython:3.14from
miss-islington:backport-6859b95-3.14miss-islington/cpython:backport-6859b95-3.14Copy head branch name to clipboard
Conversation
…ke the original class collectible (take 2) (pythonGH-137047) Remove the `__dict__` and `__weakref__` descriptors from the original class when creating a dataclass from it. An interesting hack, but more localized in scope than pythongh-135230. This may be a breaking change if people intentionally keep the original class around when using `@dataclass(slots=True)`, and then use `__dict__` or `__weakref__` on the original class. (cherry picked from commit 6859b95) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This was referenced Aug 12, 2025
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Member
|
!buildbot aarch64 Fedora Stable LTO . PGO |
|
🤖 New build scheduled with the buildbot fleet by @hugovk for commit d764eb6 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F137666%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
JelleZijlstra
approved these changes
Aug 12, 2025
kumaraditya303
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Sep 9, 2025
…ass, make the original class collectible (take 2) (pythonGH-137047) (python#137666) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove the
__dict__and__weakref__descriptors from the original class when creating a dataclass from it.An interesting hack, but more localized in scope than gh-135230.
This may be a breaking change if people intentionally keep the original class around
when using
@dataclass(slots=True), and then use__dict__or__weakref__on theoriginal class.
(cherry picked from commit 6859b95)
Co-authored-by: Jelle Zijlstra jelle.zijlstra@gmail.com
Co-authored-by: Alyssa Coghlan ncoghlan@gmail.com
Co-authored-by: Petr Viktorin encukou@gmail.com
Co-authored-by: Serhiy Storchaka storchaka@gmail.com