[issue44674] dataclasses should allow frozendict default value

Eric V. Smith report at bugs.python.org
Sun Oct 3 15:16:57 EDT 2021


Eric V. Smith <eric at trueblade.com> added the comment:

That's a good idea, Raymond.

>>> [x.__hash__ is None for x in (list, dict, set, frozenset)]
[True, True, True, False]

I don't think this change would cause any backward compatibility issues, except it would now allow a default of something bad like:

>>> class BadList(list):
...   def __hash__(self): return 0
...
>>> isinstance(BadList(), list), BadList.__hash__ is None
(True, False)

I can't say I care too much about now allowing things that didn't used to be allowed, especially if they're poorly designed like BadList.

I'll put together a PR.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44674>
_______________________________________


More information about the Python-bugs-list mailing list