mirror of https://github.com/python/cpython.git
FreeBSD doesn't follow C99 for modf(inf); so add explicit
special-value handling to math.modf code.
This commit is contained in:
parent
9f99d70513
commit
b2f7090239
|
@ -341,6 +341,15 @@ math_modf(PyObject *self, PyObject *arg)
|
||||||
double y, x = PyFloat_AsDouble(arg);
|
double y, x = PyFloat_AsDouble(arg);
|
||||||
if (x == -1.0 && PyErr_Occurred())
|
if (x == -1.0 && PyErr_Occurred())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
/* some platforms don't do the right thing for NaNs and
|
||||||
|
infinities, so we take care of special cases directly. */
|
||||||
|
if (!Py_IS_FINITE(x)) {
|
||||||
|
if (Py_IS_INFINITY(x))
|
||||||
|
return Py_BuildValue("(dd)", copysign(0., x), x);
|
||||||
|
else if (Py_IS_NAN(x))
|
||||||
|
return Py_BuildValue("(dd)", x, x);
|
||||||
|
}
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
PyFPE_START_PROTECT("in math_modf", return 0);
|
PyFPE_START_PROTECT("in math_modf", return 0);
|
||||||
x = modf(x, &y);
|
x = modf(x, &y);
|
||||||
|
|
Loading…
Reference in New Issue