- simplify parsing and printing of complex numbers
 - make complex(repr(z)) round-tripping work for complex
   numbers involving nans, infs, or negative zeros
 - don't accept some of the stranger complex strings
   that were previously allowed---e.g., complex('1..1j')
This commit is contained in:
Mark Dickinson 2009-04-24 12:46:53 +00:00
parent 508c423fe1
commit 95bc980d9e
4 changed files with 233 additions and 179 deletions

View file

@ -544,8 +544,9 @@ PyAPI_FUNC(char *) PyOS_double_to_string(double val,
}
p = result;
/* Never add sign for nan/inf, even if asked. */
if (flags & Py_DTSF_SIGN && buf[0] != '-' && t == Py_DTST_FINITE)
/* Add sign when requested. It's convenient (esp. when formatting
complex numbers) to include a sign even for inf and nan. */
if (flags & Py_DTSF_SIGN && buf[0] != '-')
*p++ = '+';
strcpy(p, buf);