Mercurial > cpython-lru_cache-weakref
diff Objects/complexobject.c @ 53396:587c8e3917c6 2.6
Issue #5829: complex('1e-500') shouldn't raise an exception.
Also fix some confusing indentation.
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Sat, 25 Apr 2009 13:16:50 +0000 |
| parents | 52294af4b663 |
| children | 9d81e2c438db |
line wrap: on
line diff
--- a/Objects/complexobject.c Sat Apr 25 12:55:56 2009 +0000 +++ b/Objects/complexobject.c Sat Apr 25 13:16:50 2009 +0000 @@ -995,16 +995,16 @@ } 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') {
