Finished backporting PEP 3127, Integer Literal Support and Syntax.
Added 0b and 0o literals to tokenizer.
Modified PyOS_strtoul to support 0b and 0o inputs.
Modified PyLong_FromString to support guessing 0b and 0o inputs.
Renamed test_hexoct.py to test_int_literal.py and added binary tests.
Added upper and lower case 0b, 0O, and 0X tests to test_int_literal.py
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 367a694..465a90c 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -180,7 +180,9 @@
def test_literals_with_leading_zeroes(self):
for arg in ["077787", "0xj", "0x.", "0e", "090000000000000",
- "080000000000000", "000000000000009", "000000000000008"]:
+ "080000000000000", "000000000000009", "000000000000008",
+ "0b42", "0BADCAFE", "0o123456789", "0b1.1", "0o4.2",
+ "0b101j2", "0o153j2", "0b100e1", "0o777e1"]:
self.assertRaises(SyntaxError, eval, arg)
self.assertEqual(eval("0777"), 511)
@@ -208,6 +210,10 @@
self.assertEqual(eval("000000000000007"), 7)
self.assertEqual(eval("000000000000008."), 8.)
self.assertEqual(eval("000000000000009."), 9.)
+ self.assertEqual(eval("0b101010"), 42)
+ self.assertEqual(eval("-0b000000000010"), -2)
+ self.assertEqual(eval("0o777"), 511)
+ self.assertEqual(eval("-0o0000010"), -8)
def test_unary_minus(self):
# Verify treatment of unary minus on negative numbers SF bug #660455