summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2008-07-16 09:40:03 +0000
committerMark Dickinson <dickinsm@gmail.com>2008-07-16 09:40:03 +0000
commitc7235b5733888b09b9d23a47bb3621b3d495093c (patch)
treeeb9681750324b261a7295780f58075aefaf49218
parent0370859fce7de1aac761d266d44f0c65d6344f5e (diff)
downloadcpython-c7235b5733888b09b9d23a47bb3621b3d495093c.tar.gz
Issue #3360: Fix incorrect parsing of "020000000000.0".
-rw-r--r--Lib/test/test_compile.py4
-rw-r--r--Misc/NEWS3
-rw-r--r--Python/ast.c11
3 files changed, 8 insertions, 10 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index e2a0ebec07..78215d2b63 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -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
diff --git a/Misc/NEWS b/Misc/NEWS
index a9ea067807..4d982704ce 100644
--- 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.
diff --git a/Python/ast.c b/Python/ast.c
index dc22478157..b6a5e0f546 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -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);