New submission from Evgeny Naumov <evgeny.nau...@pm.me>:
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. ---------- components: Library (Lib) messages: 386545 nosy: enaumov priority: normal severity: normal status: open title: `asdict` fails with frozen dataclass keys; tries to use raw dict form as key type: behavior versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43141> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com