Skip to content

gh-135228: When @dataclass(slots=True) replaces a dataclass, make the original class collectible #136893

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 3 commits into from
Jul 22, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update Lib/dataclasses.py
  • Loading branch information
JelleZijlstra authored Jul 22, 2025
commit d5450023143fc6cb5229b37ddf616e222d2d99e4
3 changes: 2 additions & 1 deletion Lib/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,8 @@ def _add_slots(cls, is_frozen, weakref_slot, defined_fields):
# Bypass mapping proxy to allow __dict__ to be removed
old_cls_dict = cls.__dict__ | _deproxier
old_cls_dict.pop('__dict__', None)
del cls.__weakref__
if "__weakref__" in cls.__dict__:
del cls.__weakref__

return newcls

Expand Down
Loading