summaryrefslogtreecommitdiffstats
path: root/Lib/dataclasses.py
diff options
context:
space:
mode:
authorAviel Boag <avboag@gmail.com>2024-03-19 00:53:14 (GMT)
committerGitHub <noreply@github.com>2024-03-19 00:53:14 (GMT)
commita22d05f04c074dbb4f71e7837f54c0bb693db75d (patch)
treea7634e879f7d77156e15f73402924ff21c92b976 /Lib/dataclasses.py
parent1d82a41235ac5619d36ac7e289fcbb686c1d9350 (diff)
downloadcpython-a22d05f04c074dbb4f71e7837f54c0bb693db75d.zip
cpython-a22d05f04c074dbb4f71e7837f54c0bb693db75d.tar.gz
cpython-a22d05f04c074dbb4f71e7837f54c0bb693db75d.tar.bz2
gh-105866: fix dataclass with slots=True, weakref_slot=True (#105870)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru> Co-authored-by: Carl Meyer <carl@oddbird.net>
Diffstat (limited to 'Lib/dataclasses.py')
-rw-r--r--Lib/dataclasses.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py
index 45ce5a9..e511eff 100644
--- a/Lib/dataclasses.py
+++ b/Lib/dataclasses.py
@@ -1159,8 +1159,10 @@ def _dataclass_setstate(self, state):
def _get_slots(cls):
match cls.__dict__.get('__slots__'):
+ # A class which does not define __slots__ at all is equivalent
+ # to a class defining __slots__ = ('__dict__', '__weakref__')
case None:
- return
+ yield from ('__dict__', '__weakref__')
case str(slot):
yield slot
# Slots may be any iterable, but we cannot handle an iterator