diff options
Diffstat (limited to 'Python/pystrtod.c')
-rw-r--r-- | Python/pystrtod.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/pystrtod.c b/Python/pystrtod.c index ce2e3825a7..703ae64563 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); |