You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following example is not working in python 3.11:
importconstruct_typedascstimportdataclassesclassTestEnum(cst.EnumBase):
one=1two=2four=4eight=8@dataclasses.dataclassclassSomeDataclass:
a: TestEnumdc=SomeDataclass(TestEnum.one)
dc_dict=dataclasses.asdict(dc) # <--- this is workingdc=SomeDataclass(TestEnum(5))
dc_dict=dataclasses.asdict(dc) # <--- Error on Python 3.11
This runs with Python 3.8-3.10 but generates the following error on Python 3.11:
Traceback (most recent call last):
File "...\construct-typing\example.py", line 21, in <module>
dc_dict = dataclasses.asdict(dc) # <--- Error on Python 3.11
^^^^^^^^^^^^^^^^^^^^^^
File "...\Python311\Lib\dataclasses.py", line 1274, in asdict
return _asdict_inner(obj, dict_factory)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "...\Python311\Lib\dataclasses.py", line 1281, in _asdict_inner
value = _asdict_inner(getattr(obj, f.name), dict_factory)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "...\Python311\Lib\dataclasses.py", line 1315, in _asdict_inner
return copy.deepcopy(obj)
^^^^^^^^^^^^^^^^^^
File "...\Python311\Lib\copy.py", line 172, in deepcopy
y = _reconstruct(x, memo, *rv)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "...\Python311\Lib\copy.py", line 265, in _reconstruct
y = func(*args)
^^^^^^^^^^^
File "...\Python311\Lib\enum.py", line 789, in __getattr__
raise AttributeError(name) from None
AttributeError: 5
It seems, that copy.deepcopy of the EnumBase is not working. Probably it has to do with the following change: python/cpython#26658
The text was updated successfully, but these errors were encountered:
The following example is not working in python 3.11:
This runs with Python 3.8-3.10 but generates the following error on Python 3.11:
It seems, that
copy.deepcopy
of theEnumBase
is not working. Probably it has to do with the following change: python/cpython#26658The text was updated successfully, but these errors were encountered: