mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
e5ca6c71cd
commit
57f282a2a0
2 changed files with 22 additions and 2 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue