[Python-checkins] r65005 - in python/trunk: Lib/test/test_compile.py Misc/NEWS Python/ast.c

mark.dickinson python-checkins at python.org
Wed Jul 16 11:40:03 CEST 2008


Author: mark.dickinson
Date: Wed Jul 16 11:40:03 2008
New Revision: 65005

Log:
Issue #3360: Fix incorrect parsing of "020000000000.0".


Modified:
   python/trunk/Lib/test/test_compile.py
   python/trunk/Misc/NEWS
   python/trunk/Python/ast.c

Modified: python/trunk/Lib/test/test_compile.py
==============================================================================
--- python/trunk/Lib/test/test_compile.py	(original)
+++ python/trunk/Lib/test/test_compile.py	Wed Jul 16 11:40:03 2008
@@ -215,6 +215,10 @@
         self.assertEqual(eval("-0b000000000010"), -2)
         self.assertEqual(eval("0o777"), 511)
         self.assertEqual(eval("-0o0000010"), -8)
+        self.assertEqual(eval("020000000000.0"), 20000000000.0)
+        self.assertEqual(eval("037777777777e0"), 37777777777.0)
+        self.assertEqual(eval("01000000000000000000000.0"),
+                         1000000000000000000000.0)
 
     def test_unary_minus(self):
         # Verify treatment of unary minus on negative numbers SF bug #660455

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Wed Jul 16 11:40:03 2008
@@ -10,6 +10,9 @@
 Core and Builtins
 -----------------
 
+- Issue #3360: Fix incorrect parsing of '020000000000.0', which
+  produced a ValueError instead of giving the correct float.
+
 - Issue #3083: Add alternate (#) formatting for bin, oct, hex output
   for str.format().  This adds the prefix 0b, 0o, or 0x, respectively.
 

Modified: python/trunk/Python/ast.c
==============================================================================
--- python/trunk/Python/ast.c	(original)
+++ python/trunk/Python/ast.c	Wed Jul 16 11:40:03 2008
@@ -3139,16 +3139,7 @@
 #endif
         if (*end == 'l' || *end == 'L')
                 return PyLong_FromString((char *)s, (char **)0, 0);
-        if (s[0] == '0') {
-                x = (long) PyOS_strtoul((char *)s, (char **)&end, 0);
-                if (x < 0 && errno == 0) {
-                                return PyLong_FromString((char *)s,
-                                                         (char **)0,
-                                                         0);
-                }
-        }
-        else
-                x = PyOS_strtol((char *)s, (char **)&end, 0);
+        x = PyOS_strtol((char *)s, (char **)&end, 0);
         if (*end == '\0') {
                 if (errno != 0)
                         return PyLong_FromString((char *)s, (char **)0, 0);


More information about the Python-checkins mailing list