[issue34363] dataclasses.asdict() mishandles dataclass instance attributes that are instances of subclassed typing.NamedTuple
Ivan Levkivskyi
report at bugs.python.org
Wed Aug 8 16:11:56 EDT 2018
Ivan Levkivskyi <levkivskyi at gmail.com> added the comment:
OK, so the crux of the bug is this difference:
>>> a = (1, 2)
>>> tuple(x for x in a)
(1, 2)
>>> NamedTupleAttribute(x for x in a)
NamedTupleAttribute(example=<generator object <genexpr> at 0x10e2e52a0>)
A potential solution would be to either use `type(obj) in (list, tuple)` instead of `isinstance(obj, (list, tuple))` (and thus cause using copy.deepcopy for everything else), but this might break some use cases (IMO quite unlikely).
Any other thoughts?
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34363>
_______________________________________
More information about the Python-bugs-list
mailing list