summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorSergey B Kirpichev <skirpichev@gmail.com>2024-05-29 07:51:19 (GMT)
committerGitHub <noreply@github.com>2024-05-29 07:51:19 (GMT)
commitcd11ff12ac55f37d38b5ef08c143c78f07da5717 (patch)
tree10a05f34466399302791c3bda940ac67170cf64f /Python
parent86d1a1aa8841ea182eaf434ae6b942b3e93f58db (diff)
downloadcpython-cd11ff12ac55f37d38b5ef08c143c78f07da5717.zip
cpython-cd11ff12ac55f37d38b5ef08c143c78f07da5717.tar.gz
cpython-cd11ff12ac55f37d38b5ef08c143c78f07da5717.tar.bz2
gh-119613: Use C99+ functions instead of Py_IS_NAN/INFINITY/FINITE (#119619)
Diffstat (limited to 'Python')
-rw-r--r--Python/ast_unparse.c2
-rw-r--r--Python/bltinmodule.c4
-rw-r--r--Python/pyhash.c4
-rw-r--r--Python/pystrtod.c6
-rw-r--r--Python/pytime.c6
5 files changed, 11 insertions, 11 deletions
diff --git a/Python/ast_unparse.c b/Python/ast_unparse.c
index 8aff045..27c3400 100644
--- a/Python/ast_unparse.c
+++ b/Python/ast_unparse.c
@@ -79,7 +79,7 @@ append_repr(_PyUnicodeWriter *writer, PyObject *obj)
return -1;
}
- if ((PyFloat_CheckExact(obj) && Py_IS_INFINITY(PyFloat_AS_DOUBLE(obj))) ||
+ if ((PyFloat_CheckExact(obj) && isinf(PyFloat_AS_DOUBLE(obj))) ||
PyComplex_CheckExact(obj))
{
PyInterpreterState *interp = _PyInterpreterState_GET();
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index d192d5b..2a02d81 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -2640,7 +2640,7 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start)
/* Avoid losing the sign on a negative result,
and don't let adding the compensation convert
an infinite or overflowed sum to a NaN. */
- if (c && Py_IS_FINITE(c)) {
+ if (c && isfinite(c)) {
f_result += c;
}
return PyFloat_FromDouble(f_result);
@@ -2672,7 +2672,7 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start)
continue;
}
}
- if (c && Py_IS_FINITE(c)) {
+ if (c && isfinite(c)) {
f_result += c;
}
result = PyFloat_FromDouble(f_result);
diff --git a/Python/pyhash.c b/Python/pyhash.c
index 5263622..4145d9e 100644
--- a/Python/pyhash.c
+++ b/Python/pyhash.c
@@ -90,8 +90,8 @@ _Py_HashDouble(PyObject *inst, double v)
double m;
Py_uhash_t x, y;
- if (!Py_IS_FINITE(v)) {
- if (Py_IS_INFINITY(v))
+ if (!isfinite(v)) {
+ if (isinf(v))
return v > 0 ? _PyHASH_INF : -_PyHASH_INF;
else
return PyObject_GenericHash(inst);
diff --git a/Python/pystrtod.c b/Python/pystrtod.c
index 16bf06f..5c8be04 100644
--- a/Python/pystrtod.c
+++ b/Python/pystrtod.c
@@ -842,7 +842,7 @@ char * PyOS_double_to_string(double val,
*/
- if (Py_IS_NAN(val) || Py_IS_INFINITY(val))
+ if (isnan(val) || isinf(val))
/* 3 for 'inf'/'nan', 1 for sign, 1 for '\0' */
bufsize = 5;
else {
@@ -860,10 +860,10 @@ char * PyOS_double_to_string(double val,
}
/* Handle nan and inf. */
- if (Py_IS_NAN(val)) {
+ if (isnan(val)) {
strcpy(buf, "nan");
t = Py_DTST_NAN;
- } else if (Py_IS_INFINITY(val)) {
+ } else if (isinf(val)) {
if (copysign(1., val) == 1.)
strcpy(buf, "inf");
else
diff --git a/Python/pytime.c b/Python/pytime.c
index 560aea3..cd76970 100644
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -375,7 +375,7 @@ pytime_object_to_denominator(PyObject *obj, time_t *sec, long *numerator,
if (PyFloat_Check(obj)) {
double d = PyFloat_AsDouble(obj);
- if (Py_IS_NAN(d)) {
+ if (isnan(d)) {
*numerator = 0;
PyErr_SetString(PyExc_ValueError, "Invalid value NaN (not a number)");
return -1;
@@ -403,7 +403,7 @@ _PyTime_ObjectToTime_t(PyObject *obj, time_t *sec, _PyTime_round_t round)
volatile double d;
d = PyFloat_AsDouble(obj);
- if (Py_IS_NAN(d)) {
+ if (isnan(d)) {
PyErr_SetString(PyExc_ValueError, "Invalid value NaN (not a number)");
return -1;
}
@@ -590,7 +590,7 @@ pytime_from_object(PyTime_t *tp, PyObject *obj, _PyTime_round_t round,
if (PyFloat_Check(obj)) {
double d;
d = PyFloat_AsDouble(obj);
- if (Py_IS_NAN(d)) {
+ if (isnan(d)) {
PyErr_SetString(PyExc_ValueError, "Invalid value NaN (not a number)");
return -1;
}