mirror of
https://github.com/python/cpython.git
synced 2025-08-23 10:16:01 +00:00
gh-102069: Fix __weakref__
descriptor generation for custom dataclasses (#102075)
This commit is contained in:
parent
71e37d9079
commit
d97757f793
3 changed files with 15 additions and 4 deletions
|
@ -1189,6 +1189,9 @@ def _add_slots(cls, is_frozen, weakref_slot):
|
|||
# Remove __dict__ itself.
|
||||
cls_dict.pop('__dict__', None)
|
||||
|
||||
# Clear existing `__weakref__` descriptor, it belongs to a previous type:
|
||||
cls_dict.pop('__weakref__', None) # gh-102069
|
||||
|
||||
# And finally create the class.
|
||||
qualname = getattr(cls, '__qualname__', None)
|
||||
cls = type(cls)(cls.__name__, cls.__bases__, cls_dict)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue