Message386545
A simple example is documented here: https://github.com/samuelcolvin/pydantic/issues/2233 but it doesn't look like it was actually filed as a bug against CPython... Copy paste of the minimal reproducing example:
from dataclasses import asdict, dataclass
@dataclass(eq=True, frozen=True)
class A:
a: str
@dataclass(eq=True, frozen=True)
class B:
b: dict[A, str]
asdict(B({A("x"):"y"}))
The offending code are these lines in dataclasses.py:
elif isinstance(obj, dict):
return type(obj)((_asdict_inner(k, dict_factory),
_asdict_inner(v, dict_factory))
The _asdict_inner(k, dict_factory) [correctly] turns dataclasses into dicts... which are not hashable. I assume there is a good reason the _asdict_inner function is called on the key, but its failure in this case looks like a (rather annoying!) error. |
|
Date |
User |
Action |
Args |
2021-02-06 05:46:54 | enaumov | set | recipients:
+ enaumov |
2021-02-06 05:46:54 | enaumov | set | messageid: <1612590414.63.0.106701107905.issue43141@roundup.psfhosted.org> |
2021-02-06 05:46:54 | enaumov | link | issue43141 messages |
2021-02-06 05:46:54 | enaumov | create | |
|