SIGN IN SIGN UP
python / cpython UNCLAIMED

The Python programming language

72153 0 0 Python

gh-135228: When @dataclass(slots=True) replaces a dataclass, make the original class collectible (take 2) (GH-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 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.


Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
J
Jelle Zijlstra committed
6859b95cfff26c9ef52c5535d2b3662f17ff5b3d
Parent: 027cacb
Committed by GitHub <noreply@github.com> on 8/12/2025, 11:16:54 AM