[issue5816] Simplify parsing of complex numbers and make complex('inf') valid.

2009-04-24 Thread Mark Dickinson
Mark Dickinson added the comment: Extra bits forward ported in r71829. Python 3.1 and 2.7 now both accept the same strings for the complex constructor. -- resolution: -> fixed status: open -> closed ___ Python tracker

[issue5816] Simplify parsing of complex numbers and make complex('inf') valid.

2009-04-24 Thread Mark Dickinson
Mark Dickinson added the comment: Backported to trunk in r71824. Leaving open, as I now need forward port some bits of r71824 which weren't in the r71818 checkin. Note that with this change, some strings which were previously accepted by the complex constructor are no longer accepted. Exampl

[issue5816] Simplify parsing of complex numbers and make complex('inf') valid.

2009-04-23 Thread Mark Dickinson
Mark Dickinson added the comment: Committed to py3k, r71818, with the changes Eric suggested. I ran build and tests both with and without the -DPY_NO_SHORT_FLOAT_REPR compiler option. Will backport. -- versions: +Python 2.7 -Python 3.1 ___ Python

[issue5816] Simplify parsing of complex numbers and make complex('inf') valid.

2009-04-23 Thread Eric Smith
Eric Smith added the comment: The fallback code, around line 633 in the patched version of pystrtod.c, probably also needs to be modified. It's this code that would need backporting to 2.7. -- ___ Python tracker __

[issue5816] Simplify parsing of complex numbers and make complex('inf') valid.

2009-04-23 Thread Eric Smith
Eric Smith added the comment: Wow, that does greatly simplify printing. One nit: the variable named 'im' isn't needed any more, you could just use 'pim'. Not sure if the asymmetry with 're' and 'pre' is worthwhile, though. Mark Dickinson wrote: > 6. Change PyOS_ascii_strtod to always output a

[issue5816] Simplify parsing of complex numbers and make complex('inf') valid.

2009-04-23 Thread Mark Dickinson
Mark Dickinson added the comment: Updated patch: 4. also simplify complex printing: no special handling for nans or infinities. This means that e.g. complex(1, inf) prints as "1 + infj" instead of "1+inf*j". This might look ugly, but I think it's better than what was there befor

[issue5816] Simplify parsing of complex numbers and make complex('inf') valid.

2009-04-22 Thread Mark Dickinson
Changes by Mark Dickinson : -- assignee: -> marketdickinson components: +Interpreter Core priority: -> normal stage: -> patch review type: -> behavior versions: +Python 3.1 ___ Python tracker ___

[issue5816] Simplify parsing of complex numbers and make complex('inf') valid.

2009-04-22 Thread Mark Dickinson
New submission from Mark Dickinson : Here's a patch that: 1. greatly simplifies the complex parsing code in Objects/complexobject.c 2. allows nans and infinities in constructing a complex number from a string 3. fixes missing out-of-memory checks (PyOS_ascii_strtod can fail due to lac