Skip to content
Merged
4 changes: 3 additions & 1 deletion Lib/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,8 +1172,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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed `_get_slots` bug which caused error when defining dataclasses with slots and a weakref_slot.