TypeError when creating frozenset with no hash
andrew cooke
andrew at acooke.org
Sat Mar 14 18:58:00 EDT 2009
I was going to file a bug report for this, but then I wondered if it was
considered normal behaviour. Am I wrong in thinking there should be a
better error message?
>>> class NoHash:
... def __hash__(self):
... pass
...
>>> frozenset([NoHash()])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: an integer is required
I understand that there is a real problem here (in my code I had forgotten
the "return"); the issue is whether the stack trace should contain some
reference to __hash__ or similar. Perhaps that is impossible for
containers implemented in C?
Thanks,
Andrew
More information about the Python-list
mailing list