]> granicus.if.org Git - python/commitdiff
Issue2681: the literal 0o8 was wrongly accepted, and evaluated as float(0.0).
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Thu, 24 Apr 2008 18:07:05 +0000 (18:07 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Thu, 24 Apr 2008 18:07:05 +0000 (18:07 +0000)
This happened only when 8 is the first digit.
Credits go to Lukas Meuser.

Lib/test/test_compile.py
Misc/NEWS
Parser/tokenizer.c

index e8695acc46a79ae9d49ca74e60312eae54dacdc1..e2a0ebec07d751dcab55d8c95d6f11964522bfdd 100644 (file)
@@ -183,7 +183,7 @@ if 1:
         for arg in ["077787", "0xj", "0x.", "0e",  "090000000000000",
                     "080000000000000", "000000000000009", "000000000000008",
                     "0b42", "0BADCAFE", "0o123456789", "0b1.1", "0o4.2",
-                    "0b101j2", "0o153j2", "0b100e1", "0o777e1"]:
+                    "0b101j2", "0o153j2", "0b100e1", "0o777e1", "0o8", "0o78"]:
             self.assertRaises(SyntaxError, eval, arg)
 
         self.assertEqual(eval("0777"), 511)
index 3930929267db1f2d706763a01a44a7f7dd7074e9..52aee8026fa56561c4a775d4929d1beaa5750e6c 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 3?
 Core and builtins
 -----------------
 
+- Issue #2681: The octal literal ``0o8`` was incorrecly acctepted. Now it
+  properly raises a SyntaxError.
+
 - Patch #2617: Reserved -J and -X arguments for Jython, IronPython and other
   implementations of Python. 
 
index 29fb1142917e145327ae5e4522ca289c53aa7d45..1d0a4aa3f23b438dc5c17185bbd973130582f436 100644 (file)
@@ -1351,7 +1351,7 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
                         else if (c == 'o' || c == 'O') {
                                /* Octal */
                                c = tok_nextc(tok);
-                               if (c < '0' || c > '8') {
+                               if (c < '0' || c >= '8') {
                                        tok->done = E_TOKEN;
                                        tok_backup(tok, c);
                                        return ERRORTOKEN;