[Python-checkins] python/dist/src/Lib decimal.py,1.31.2.1,1.31.2.2
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Wed Mar 16 00:36:22 CET 2005
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32366/lib
Modified Files:
Tag: release24-maint
decimal.py
Log Message:
Decimal special values did not hash properly.
Index: decimal.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v
retrieving revision 1.31.2.1
retrieving revision 1.31.2.2
diff -u -d -r1.31.2.1 -r1.31.2.2
--- decimal.py 18 Dec 2004 19:12:11 -0000 1.31.2.1
+++ decimal.py 15 Mar 2005 23:36:19 -0000 1.31.2.2
@@ -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