Author: Antonio Cuni <[email protected]>
Branch: 
Changeset: r58183:2da948c3eb75
Date: 2012-10-17 18:57 +0200
http://bitbucket.org/pypy/pypy/changeset/2da948c3eb75/

Log:    add one more edge case to complex parsing

diff --git a/pypy/objspace/std/complextype.py b/pypy/objspace/std/complextype.py
--- a/pypy/objspace/std/complextype.py
+++ b/pypy/objspace/std/complextype.py
@@ -26,9 +26,11 @@
     imagstop = 0
     imagsign = ' '
     i = 0
-    # ignore whitespace
+    # ignore whitespace at beginning and end
     while i < slen and s[i] == ' ':
         i += 1
+    while slen > 0 and s[slen-1] == ' ':
+        slen -= 1
 
     if s[i] == '(' and s[slen-1] == ')':
         i += 1
diff --git a/pypy/objspace/std/test/test_complexobject.py 
b/pypy/objspace/std/test/test_complexobject.py
--- a/pypy/objspace/std/test/test_complexobject.py
+++ b/pypy/objspace/std/test/test_complexobject.py
@@ -304,7 +304,7 @@
         assert self.almost_equal(complex(),  0)
         assert self.almost_equal(complex("-1"), -1)
         assert self.almost_equal(complex("+1"), +1)
-        assert self.almost_equal(complex(" ( +3.14-6J )"), 3.14-6j)
+        assert self.almost_equal(complex(" ( +3.14-6J ) "), 3.14-6j)
 
         class complex2(complex):
             pass
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to