[Python-checkins] python/dist/src/Lib decimal.py,1.34,1.35

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Tue Mar 15 05:59:20 CET 2005


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2896/Lib

Modified Files:
	decimal.py 
Log Message:
Bug #1163325:  "special" decimals aren't hashable



Index: decimal.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- decimal.py	1 Mar 2005 03:12:26 -0000	1.34
+++ decimal.py	15 Mar 2005 04:59:16 -0000	1.35
@@ -728,6 +728,10 @@
         # 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)



More information about the Python-checkins mailing list