Try to recover from that glibc's ldexp apparently doesn't set errno on

overflow.  Needs testing on Linux (test_long.py and test_long_future.py
especially).
This commit is contained in:
Tim Peters 2001-09-05 05:38:10 +00:00
parent e5ca6c71cd
commit 57f282a2a0
2 changed files with 22 additions and 2 deletions

View file

@ -545,7 +545,7 @@ PyLong_AsDouble(PyObject *vv)
goto overflow;
errno = 0;
x = ldexp(x, e * SHIFT);
if (errno == ERANGE)
if (Py_OVERFLOWED(x))
goto overflow;
return x;
@ -1607,7 +1607,7 @@ long_true_divide(PyObject *v, PyObject *w)
goto overflow;
errno = 0;
ad = ldexp(ad, aexp * SHIFT);
if (ad != 0 && errno == ERANGE) /* ignore underflow to 0.0 */
if (Py_OVERFLOWED(ad)) /* ignore underflow to 0.0 */
goto overflow;
return PyFloat_FromDouble(ad);