Issue #10356: Decimal(-1).__hash__() should equal hash(Decimal(-1)).

This commit is contained in:
Stefan Krah 2010-11-17 11:16:34 +00:00
parent 3ec60183a4
commit dc817b229c
3 changed files with 25 additions and 15 deletions

View file

@ -957,7 +957,8 @@ class Decimal(object):
else:
exp_hash = pow(_PyHASH_10INV, -self._exp, _PyHASH_MODULUS)
hash_ = int(self._int) * exp_hash % _PyHASH_MODULUS
return hash_ if self >= 0 else -hash_
ans = hash_ if self >= 0 else -hash_
return -2 if ans == -1 else ans
def as_tuple(self):
"""Represents the number as a triple tuple.