mirror of
https://github.com/python/cpython.git
synced 2025-11-01 06:01:29 +00:00
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>
This commit is contained in:
parent
1d82a41235
commit
a22d05f04c
3 changed files with 15 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue