]> granicus.if.org Git - python/commitdiff
Issue #3360: Fix incorrect parsing of "020000000000.0".
authorMark Dickinson <dickinsm@gmail.com>
Wed, 16 Jul 2008 09:40:03 +0000 (09:40 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Wed, 16 Jul 2008 09:40:03 +0000 (09:40 +0000)
Lib/test/test_compile.py
Misc/NEWS
Python/ast.c

index e2a0ebec07d751dcab55d8c95d6f11964522bfdd..78215d2b63a6fc066ef4d84f44130c7e03a87991 100644 (file)
@@ -215,6 +215,10 @@ if 1:
         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
index a9ea0678070d1fb90358e96011700c1dde2cbddb..4d982704ce2aa89e4dc1c2fed5b07d4fc28686c1 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 2.6 beta 2?
 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.
 
index dc224781579d39a7f8ae050e6d498bbe923cdc77..b6a5e0f546f4881b1513a18a59b40825482c3209 100644 (file)
@@ -3139,16 +3139,7 @@ parsenumber(struct compiling *c, const char *s)
 #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);