Commits

Amaury Forgeot d'Arc  committed 78e5ec0 Merge

merge heads

  • Participants
  • Parent commits e0d46e4, d9459af

Comments (0)

Files changed (2)

File pypy/objspace/std/complextype.py

     if s[i] == '(' and s[slen-1] == ')':
         i += 1
         slen -= 1
+        # ignore whitespace after bracket
+        while i < slen and s[i] == ' ':
+            i += 1
 
     # extract first number
     realstart = i

File pypy/objspace/std/test/test_complexobject.py

         test_cparse('.e+5', '.e+5', '0.0')
         test_cparse('(1+2j)', '1', '2')
         test_cparse('(1-6j)', '1', '-6')
+        test_cparse(' ( +3.14-6J )','+3.14','-6')
 
     def test_unpackcomplex(self):
         space = self.space
         h.assertAlmostEqual(complex(),  0)
         h.assertAlmostEqual(complex("-1"), -1)
         h.assertAlmostEqual(complex("+1"), +1)
+        h.assertAlmostEqual(complex(" ( +3.14-6J )"), 3.14-6j)
 
         class complex2(complex): pass
         h.assertAlmostEqual(complex(complex2(1+1j)), 1+1j)
         x.foo = 42
         assert x.foo == 42
         assert type(complex(x)) == complex
-    
+
     def test_infinity(self):
         inf = 1e200*1e200
         assert complex("1"*500) == complex(inf)
         assert complex("-inf") == complex(-inf)
-        
+
     def test_repr(self):
         assert repr(1+6j) == '(1+6j)'
         assert repr(1-6j) == '(1-6j)'