diff options
author | Raymond Hettinger <python@rcn.com> | 2005-03-15 04:59:17 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2005-03-15 04:59:17 (GMT) |
commit | bea3f6f5c788eb4f0f7639913ff89654152864c0 (patch) | |
tree | cf95d7cf88b4f8f77f05344b2eb7dfd80617cb0b /Lib/decimal.py | |
parent | 141f41ae1a38746578f3cecd204ec04b4006b9e1 (diff) | |
download | cpython-bea3f6f5c788eb4f0f7639913ff89654152864c0.zip cpython-bea3f6f5c788eb4f0f7639913ff89654152864c0.tar.gz cpython-bea3f6f5c788eb4f0f7639913ff89654152864c0.tar.bz2 |
Bug #1163325: "special" decimals aren't hashable
Diffstat (limited to 'Lib/decimal.py')
-rw-r--r-- | Lib/decimal.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py index 7f71b83..fb11e8f 100644 --- a/Lib/decimal.py +++ b/Lib/decimal.py @@ -728,6 +728,10 @@ class Decimal(object): # Decimal integers must hash the same as the ints # Non-integer decimals are normalized and hashed as strings # Normalization assures that hast(100E-1) == hash(10) + if self._is_special: + if self._isnan(): + raise TypeError('Cannot hash a NaN value.') + return hash(str(self)) i = int(self) if self == Decimal(i): return hash(i) |