summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-04-24 12:46:53 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-04-24 12:46:53 (GMT)
commit95bc980d9ee2aabfedb90512906247f3e3c3fdf7 (patch)
tree1ed910c7fec0165c3faa9eea7f3b522fbe285e3c /Python
parent508c423fe10961b28d6c36eb3ffb25d4f6f5c552 (diff)
downloadcpython-95bc980d9ee2aabfedb90512906247f3e3c3fdf7.zip
cpython-95bc980d9ee2aabfedb90512906247f3e3c3fdf7.tar.gz
cpython-95bc980d9ee2aabfedb90512906247f3e3c3fdf7.tar.bz2
Issue #5816:
- 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')
Diffstat (limited to 'Python')
-rw-r--r--Python/pystrtod.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/pystrtod.c b/Python/pystrtod.c
index ce2e382..703ae64 100644
--- a/Python/pystrtod.c
+++ b/Python/pystrtod.c
@@ -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);