diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2023-03-13 21:42:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-13 21:42:05 (GMT) |
commit | d97757f793ea53dda3cc6882b4a92d3e921b17c9 (patch) | |
tree | a5bc4852eaa2d04af37975ae1f1f9b13c4757ece /Lib/dataclasses.py | |
parent | 71e37d907905b0504c5bb7b25681adeea2157492 (diff) | |
download | cpython-d97757f793ea53dda3cc6882b4a92d3e921b17c9.zip cpython-d97757f793ea53dda3cc6882b4a92d3e921b17c9.tar.gz cpython-d97757f793ea53dda3cc6882b4a92d3e921b17c9.tar.bz2 |
gh-102069: Fix `__weakref__` descriptor generation for custom dataclasses (#102075)
Diffstat (limited to 'Lib/dataclasses.py')
-rw-r--r-- | Lib/dataclasses.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py index 7c3285c..82b08fc 100644 --- a/Lib/dataclasses.py +++ b/Lib/dataclasses.py @@ -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) |