mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #10356: Decimal(-1).__hash__() should equal hash(Decimal(-1)).
This commit is contained in:
parent
3ec60183a4
commit
dc817b229c
3 changed files with 25 additions and 15 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue