]> granicus.if.org Git - python/commitdiff
Issue #10356: hash(Decimal("sNaN")) now raises ValueError instead of TypeError.
authorStefan Krah <stefan@bytereef.org>
Thu, 18 Nov 2010 15:20:34 +0000 (15:20 +0000)
committerStefan Krah <stefan@bytereef.org>
Thu, 18 Nov 2010 15:20:34 +0000 (15:20 +0000)
Lib/decimal.py
Lib/test/test_decimal.py
Misc/NEWS

index 5a9f840771148855c89464985cd7e50bb46596f2..b78c2c5774182cea073252e837421ff8fee1c328 100644 (file)
@@ -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:
index 611ef55007336db1445fce948b255a5d18ea5bd5..b07fb1ddb8726a4da9efb809a107e5c50682cd6c 100644 (file)
@@ -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')))
 
index ae26a990b9a3136a758ac56a2e715c918690409a..8ab404d88f4756ece8dc6c9c3e1816bfff11e229 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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.