[Python-checkins] python/dist/src/Lib decimal.py,1.30,1.31
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Wed Nov 24 08:28:51 CET 2004
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2088
Modified Files:
decimal.py
Log Message:
SF bug #1071588 coercing decimal to int doesn't work between -1 and 1
Index: decimal.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- decimal.py 27 Oct 2004 06:21:46 -0000 1.30
+++ decimal.py 24 Nov 2004 07:28:48 -0000 1.31
@@ -1410,14 +1410,14 @@
return context._raise_error(InvalidContext)
elif self._isinfinity():
raise OverflowError, "Cannot convert infinity to long"
- if not self:
- return 0
- sign = '-'*self._sign
if self._exp >= 0:
- s = sign + ''.join(map(str, self._int)) + '0'*self._exp
- return int(s)
- s = sign + ''.join(map(str, self._int))[:self._exp]
- return int(s)
+ s = ''.join(map(str, self._int)) + '0'*self._exp
+ else:
+ s = ''.join(map(str, self._int))[:self._exp]
+ if s == '':
+ s = '0'
+ sign = '-'*self._sign
+ return int(sign + s)
def __long__(self):
"""Converts to a long.
More information about the Python-checkins
mailing list