[Python-checkins] r62480 - in python/trunk: Lib/test/test_compile.py Misc/NEWS Parser/tokenizer.c

amaury.forgeotdarc python-checkins at python.org
Thu Apr 24 20:07:22 CEST 2008


Author: amaury.forgeotdarc
Date: Thu Apr 24 20:07:05 2008
New Revision: 62480

Log:
Issue2681: the literal 0o8 was wrongly accepted, and evaluated as float(0.0).
This happened only when 8 is the first digit.
Credits go to Lukas Meuser.


Modified:
   python/trunk/Lib/test/test_compile.py
   python/trunk/Misc/NEWS
   python/trunk/Parser/tokenizer.c

Modified: python/trunk/Lib/test/test_compile.py
==============================================================================
--- python/trunk/Lib/test/test_compile.py	(original)
+++ python/trunk/Lib/test/test_compile.py	Thu Apr 24 20:07:05 2008
@@ -183,7 +183,7 @@
         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)

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Thu Apr 24 20:07:05 2008
@@ -12,6 +12,9 @@
 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. 
 

Modified: python/trunk/Parser/tokenizer.c
==============================================================================
--- python/trunk/Parser/tokenizer.c	(original)
+++ python/trunk/Parser/tokenizer.c	Thu Apr 24 20:07:05 2008
@@ -1351,7 +1351,7 @@
                         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;


More information about the Python-checkins mailing list