Skip to content

[3.14] gh-135228: When @dataclass(slots=True) replaces a dataclass, make the original class collectible (take 2) (GH-137047) #137666

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

Merged
merged 1 commit into from
Aug 12, 2025

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Aug 12, 2025

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 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

…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>
@hugovk

This comment was marked as outdated.

@bedevere-bot

This comment was marked as outdated.

@hugovk
Copy link
Member

hugovk commented Aug 12, 2025

!buildbot aarch64 Fedora Stable LTO . PGO

@bedevere-bot
Copy link

🤖 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: aarch64 Fedora Stable LTO . PGO

The builders matched are:

  • aarch64 Fedora Stable LTO + PGO PR

@hugovk hugovk merged commit 4dda176 into python:3.14 Aug 12, 2025
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

5 participants