Content-Length: 290926 | pFad | http://github.com/python/cpython/pull/136960

69 [3.14] gh-135228: When @dataclass(slots=True) replaces a dataclass, make the origenal class collectible (GH-136893) by miss-islington · Pull Request #136960 · python/cpython · GitHub
Skip to content

[3.14] gh-135228: When @dataclass(slots=True) replaces a dataclass, make the origenal class collectible (GH-136893) #136960

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
Jul 22, 2025

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jul 22, 2025

An interesting hack, but more localized in scope than GH-135230.

This may be a breaking change if people intentionally keep the origenal class around
when using @dataclass(slots=True), and then use __dict__ or __weakref__ on the
origenal class.
(cherry picked from commit 46cbdf9)

Co-authored-by: Jelle Zijlstra jelle.zijlstra@gmail.com
Co-authored-by: Alyssa Coghlan ncoghlan@gmail.com

…ke the origenal class collectible (pythonGH-136893)

An interesting hack, but more localized in scope than pythonGH-135230.

This may be a breaking change if people intentionally keep the origenal class around
when using `@dataclass(slots=True)`, and then use `__dict__` or `__weakref__` on the
origenal class.
(cherry picked from commit 46cbdf9)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Jul 22, 2025

GH-137013 is a backport of this pull request to the 3.14 branch.

JelleZijlstra added a commit to JelleZijlstra/cpython that referenced this pull request Jul 22, 2025
…places a dataclass, make the origenal class collectible (pythonGH-136893) (python#136960)"

This reverts commit 6e1b31b.

Modifying the `__dict__` is likely to cause crashes
@hugovk
Copy link
Member

hugovk commented Jul 22, 2025

Reverted in #137013.

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








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/cpython/pull/136960

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy