summaryrefslogtreecommitdiffstats
path: root/Lib/decimal.py
diff options
context:
space:
mode:
authorStefan Krah <stefan@bytereef.org>2010-11-17 11:16:34 (GMT)
committerStefan Krah <stefan@bytereef.org>2010-11-17 11:16:34 (GMT)
commitdc817b229c972b2a881d08834a0612232dac7415 (patch)
tree0817f2bf1233fc07425430315cd838c63ffc5a86 /Lib/decimal.py
parent3ec60183a4e346dd2b12f4bb14dfbc2f90fe8218 (diff)
downloadcpython-dc817b229c972b2a881d08834a0612232dac7415.zip
cpython-dc817b229c972b2a881d08834a0612232dac7415.tar.gz
cpython-dc817b229c972b2a881d08834a0612232dac7415.tar.bz2
Issue #10356: Decimal(-1).__hash__() should equal hash(Decimal(-1)).
Diffstat (limited to 'Lib/decimal.py')
-rw-r--r--Lib/decimal.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py
index c3dffa3..5a9f840 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -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.