]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-42323: Fix math.nextafter() for NaN on AIX (GH-24265)
authorVictor Stinner <vstinner@python.org>
Wed, 20 Jan 2021 14:20:13 +0000 (15:20 +0100)
committerGitHub <noreply@github.com>
Wed, 20 Jan 2021 14:20:13 +0000 (15:20 +0100)
Misc/NEWS.d/next/Library/2021-01-20-12-10-47.bpo-42323.PONB8e.rst [new file with mode: 0644]
Modules/mathmodule.c

diff --git a/Misc/NEWS.d/next/Library/2021-01-20-12-10-47.bpo-42323.PONB8e.rst b/Misc/NEWS.d/next/Library/2021-01-20-12-10-47.bpo-42323.PONB8e.rst
new file mode 100644 (file)
index 0000000..b2f7bec
--- /dev/null
@@ -0,0 +1 @@
+Fix :func:`math.nextafter` for NaN on AIX.
index 86b64fb42269078b72073fedf9b00d6afcfee468..8133d6b3aaefb8341924476aaaafa5370ed24078 100644 (file)
@@ -3473,6 +3473,12 @@ math_nextafter_impl(PyObject *module, double x, double y)
            Bug fixed in bos.adt.libm 7.2.2.0 by APAR IV95512. */
         return PyFloat_FromDouble(y);
     }
+    if (Py_IS_NAN(x)) {
+        return x;
+    }
+    if (Py_IS_NAN(y)) {
+        return y;
+    }
 #endif
     return PyFloat_FromDouble(nextafter(x, y));
 }