Commits

Alex Gaynor committed 1f581d2

Fix parsing for complex("+J")

  • Participants
  • Parent commits f0d22ef

Comments (0)

Files changed (2)

File pypy/objspace/std/complextype.py

         if s[newstop] in ('j','J'):
             if realstart == newstop:
                 imagpart = '1.0'
+            elif realstart == newstop-1 and s[realstart] == '+':
+                imagpart = '1.0'
+            elif realstart == newstop-1 and s[realstart] == '-':
+                imagpart = '-1.0'
             else:
                 imagpart = s[realstart:newstop]
             return '0.0', imagpart

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

         test_cparse('(1+2j)', '1', '2')
         test_cparse('(1-6j)', '1', '-6')
         test_cparse(' ( +3.14-6J )','+3.14','-6')
+        test_cparse(' +J','0.0','1.0')
+        test_cparse(' -J','0.0','-1.0')
 
     def test_unpackcomplex(self):
         space = self.space