◐ Shell
clean mode source ↗

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

…ke the original 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 original class around
when using `@dataclass(slots=True)`, and then use `__dict__` or `__weakref__` on the
original class.
(cherry picked from commit 46cbdf9)

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

This was referenced

Jul 22, 2025

JelleZijlstra added a commit to JelleZijlstra/cpython that referenced this pull request

Jul 22, 2025

kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull request

Sep 9, 2025
…ass, make the original class collectible (pythonGH-136893) (python#136960)

pythongh-135228: When @DataClass(slots=True) replaces a dataclass, make the original 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 original class around
when using `@dataclass(slots=True)`, and then use `__dict__` or `__weakref__` on the
original class.
(cherry picked from commit 46cbdf9)

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