aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/dataclasses.py
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2023-03-14 00:42:05 +0300
committerGitHub <noreply@github.com>2023-03-13 15:42:05 -0600
commitd97757f793ea53dda3cc6882b4a92d3e921b17c9 (patch)
treea5bc4852eaa2d04af37975ae1f1f9b13c4757ece /Lib/dataclasses.py
parent71e37d907905b0504c5bb7b25681adeea2157492 (diff)
downloadcpython-d97757f793ea53dda3cc6882b4a92d3e921b17c9.tar.gz
cpython-d97757f793ea53dda3cc6882b4a92d3e921b17c9.zip
gh-102069: Fix `__weakref__` descriptor generation for custom dataclasses (#102075)
Diffstat (limited to 'Lib/dataclasses.py')
-rw-r--r--Lib/dataclasses.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py
index 7c3285cf440..82b08fc0178 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)