SF #660455 : patch by NNorwitz.

"Unsigned" (i.e., positive-looking, but really negative) hex/oct
constants with a leading minus sign are once again properly negated.
The micro-optimization for negated numeric constants did the wrong
thing for such hex/oct constants.  The patch avoids the optimization
for all hex/oct constants.

This needs to be backported to Python 2.2!
This commit is contained in:
Guido van Rossum 2003-02-12 16:57:47 +00:00
parent e71b9f830b
commit 66b1259dbc
3 changed files with 14 additions and 8 deletions

View file

@ -37,7 +37,9 @@ try:
except ImportError:
maxint = 2147483647
if maxint == 2147483647:
if -2147483647-1 != -020000000000: raise TestFailed, 'max negative int'
# The following test will start to fail in Python 2.4;
# change the 020000000000 to -020000000000
if -2147483647-1 != 020000000000: raise TestFailed, 'max negative int'
# XXX -2147483648
if 037777777777 != -1: raise TestFailed, 'oct -1'
if 0xffffffff != -1: raise TestFailed, 'hex -1'