diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-04-25 13:16:50 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-04-25 13:16:50 (GMT) |
commit | 22999a69e1e810757823abef87b744ad3686f908 (patch) | |
tree | 628d57dd33361b55949705375334f1248d0716b0 /Objects | |
parent | de0d5e3247ab17f481af07b548dc930ddfd80740 (diff) | |
download | cpython-22999a69e1e810757823abef87b744ad3686f908.zip cpython-22999a69e1e810757823abef87b744ad3686f908.tar.gz cpython-22999a69e1e810757823abef87b744ad3686f908.tar.bz2 |
Issue #5829: complex('1e-500') shouldn't raise an exception.
Also fix some confusing indentation.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/complexobject.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Objects/complexobject.c b/Objects/complexobject.c index 9943d0d..8ce61b7 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -995,16 +995,16 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v) } errno = 0; PyFPE_START_PROTECT("strtod", return 0) - z = PyOS_ascii_strtod(s, &end) ; + z = PyOS_ascii_strtod(s, &end) ; PyFPE_END_PROTECT(z) - if (errno != 0) { - PyOS_snprintf(buffer, sizeof(buffer), - "float() out of range: %.150s", s); - PyErr_SetString( - PyExc_ValueError, - buffer); - return NULL; - } + if (errno == ERANGE && fabs(z) >= 1.0) { + PyOS_snprintf(buffer, sizeof(buffer), + "float() out of range: %.150s", s); + PyErr_SetString( + PyExc_ValueError, + buffer); + return NULL; + } s=end; if (*s=='J' || *s=='j') { |