New submission from Gregory Golberg :
On some Python builds (2.5.2 and 2.6.1) the following program:
import sys
from decimal import Decimal
def show(n):
print type(n)
d = Decimal(str(n))
i = int(d)
t = type(i)
print t
i2 = int(i)
t2 = type(i2)
print t2
n = - sys.maxint - 1
show(n)
prints
While on 2.4 and 2.5.1 it prints:
This seems to happen only with -sys.maxint-1 number!
This has been tested with the following builds:
*** "Strange" result (with long): ***
2.6.1 (r261:67515, Feb 26 2009, 12:21:28) [GCC 4.2.4 (Ubuntu
4.2.4-1ubuntu3)]
2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]
2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu
4.2.3-2ubuntu7)]
2.5.2 and 2.6.1 on Windows Server 2003
*** "Expected" result (all int): ***
2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]
2.5.1 (r251:54863, Oct 15 2007, 13:50:22) [GCC 3.4.6 20060404 (Red Hat
3.4.6-3)]
2.5.1 (r251:54863, Jul 31 2008, 23:17:40) [GCC 4.1.3 20070929
(prerelease) (Ubuntu 4.1.2-16ubuntu2)]
2.4.5 (#2, Aug 1 2008, 02:20:59) [GCC 4.3.1]
2.4.5 (#1, Jul 22 2008, 08:30:02) [GCC 3.4.3 (csl-sol210-3_4-20050802)]
2.4.3 (#1, Sep 21 2007, 20:05:43) [GCC 3.4.6 20060404 (Red Hat 3.4.6-8)]
--
assignee: theller
components: Interpreter Core, ctypes
files: negmaxintbug.py
messages: 82773
nosy: debedb, theller
severity: normal
status: open
title: Strange behavior when performing int on a Decimal made from -sys.maxint-1
type: behavior
versions: Python 2.5, Python 2.6
Added file: http://bugs.python.org/file13191/negmaxintbug.py
___
Python tracker
<http://bugs.python.org/issue5377>
___
___
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com