Commit d8b661dd authored by Stefan Krah's avatar Stefan Krah

Issue #10356: hash(Decimal("sNaN")) now raises ValueError instead of TypeError.

parent d28f790b
......@@ -943,7 +943,7 @@ class Decimal(object):
# in the documentation. (See library docs, 'Built-in Types').
if self._is_special:
if self.is_snan():
raise TypeError('Cannot hash a signaling NaN value.')
raise ValueError('Cannot hash a signaling NaN value.')
elif self.is_nan():
return _PyHASH_NAN
else:
......
......@@ -1346,7 +1346,7 @@ class DecimalUsabilityTest(unittest.TestCase):
#the same hash that to an int
self.assertEqual(hashit(Decimal(23)), hashit(23))
self.assertRaises(TypeError, hash, Decimal('sNaN'))
self.assertRaises(ValueError, hash, Decimal('sNaN'))
self.assertTrue(hashit(Decimal('Inf')))
self.assertTrue(hashit(Decimal('-Inf')))
......
......@@ -104,6 +104,9 @@ Core and Builtins
Library
-------
- Issue #10356: hash(Decimal("sNaN")) now raises ValueError instead of
TypeError.
- Issue #10356: Decimal.__hash__(-1) should return -2.
- Issue #1553375: logging: Added stack_info kwarg to display stack information.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment