[issue10356] decimal.py: hash of -1

Raymond Hettinger report at bugs.python.org
Thu Nov 18 21:20:17 CET 2010

Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

The choice between ValueError and TypeError can sometimes be ambiguous and seem arbitrary and I understand why you're gravitating towards ValueError (because it works some values and not others), but in this case the API is already fixed by what hash() does elsewhere.

It is no fair to users to have to wrap hash(x) calls with a try/except that catches both exceptions.  So, we should still to a consistent hash API:

  >>> hash([])
  Traceback (most recent call last):
    File "<pyshell#1>", line 1, in <module>
  TypeError: unhashable type: 'list'

In this case, practicality beats purity and released beats unreleased.

status: closed -> open

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list