diff options
-rw-r--r-- | Lib/test/test_compile.py | 15 | ||||
-rw-r--r-- | Lib/test/test_grammar.py | 4 | ||||
-rw-r--r-- | Python/compile.c | 3 |
3 files changed, 14 insertions, 8 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index 4b522ac..1fe7f52 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -133,9 +133,12 @@ expect_same("000000000000007", 7) expect_same("000000000000008.", 8.) expect_same("000000000000009.", 9.) -## # Verify treatment of unary minus on negative numbers SF bug #660455 -## import warnings -## warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning) -## # XXX Of course the following test will have to be changed in Python 2.4 -## expect_same("0xffffffff", -1) -## expect_same("-0xffffffff", 1) +# Verify treatment of unary minus on negative numbers SF bug #660455 +import warnings +warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning) +# XXX Of course the following test will have to be changed in Python 2.4 +# This test is in a <string> so the filterwarnings() can affect it +exec """ +expect_same("0xffffffff", -1) +expect_same("-0xffffffff", 1) +""" diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index e0667d8..ea0a88c 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -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' diff --git a/Python/compile.c b/Python/compile.c index 2b2a9d5..717b3ff 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2069,7 +2069,8 @@ com_factor(struct compiling *c, node *n) && NCH(ppower) == 1 && TYPE((patom = CHILD(ppower, 0))) == atom && TYPE((pnum = CHILD(patom, 0))) == NUMBER - && !(childtype == MINUS && is_float_zero(STR(pnum)))) { + && !(childtype == MINUS && + (STR(pnum)[0] == '0' || is_float_zero(STR(pnum))))) { if (childtype == TILDE) { com_invert_constant(c, pnum); return; |