This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients debedb, theller, vstinner
Date 2009-02-26.23:32:54
SpamBayes Score 3.3742293e-09
Marked as misclassified No
Message-id <1235691176.78.0.14029827293.issue5377@psf.upfronthosting.co.za>
In-reply-to
Content
For a Decimal object (d), int(d) calls d.__int__(). In your example, d 
has the attributes:
* _sign=1 (negative)
* _exp=0 (10^0=1)
* _int='2147483648'

d.__int__() uses s*int(self._int)*10**self._exp 
<=> -(int('2147483648')). Since int('2147483648') creates a long, you 
finally get a long instead of an integer.

Workaround to get a small integer even with -2147483648: 
int(int(d)) ;-)

For me, it's not a bug because __int__() can return a long! The 
following code works in Python 2.5 and 2.6:
   class A:
       def __int__(self):
           return 10**20
History
Date User Action Args
2009-02-26 23:32:57vstinnersetrecipients: + vstinner, theller, debedb
2009-02-26 23:32:56vstinnersetmessageid: <1235691176.78.0.14029827293.issue5377@psf.upfronthosting.co.za>
2009-02-26 23:32:55vstinnerlinkissue5377 messages
2009-02-26 23:32:54vstinnercreate