]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-141004: Document `Py_RETURN_NAN` and `Py_RETURN_INF` (GH-141029) (GH-141075)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 5 Nov 2025 22:06:41 +0000 (23:06 +0100)
committerGitHub <noreply@github.com>
Wed, 5 Nov 2025 22:06:41 +0000 (22:06 +0000)
gh-141004: Document `Py_RETURN_NAN` and `Py_RETURN_INF` (GH-141029)
(cherry picked from commit 5b02c6e920aaef4b202fc19186f742d008460fd3)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Doc/c-api/float.rst

index cf91ff74c1fbff76733f321d759c1587c79dc17a..dddf126fe084c3fd88ef65adcd03aad9f4444f47 100644 (file)
@@ -78,6 +78,23 @@ Floating-Point Objects
    Return the minimum normalized positive float *DBL_MIN* as C :c:expr:`double`.
 
 
+.. c:macro:: Py_RETURN_NAN
+
+   Return :data:`math.nan` from a function.
+
+   On most platforms, this is equivalent to ``return PyFloat_FromDouble(NAN)``.
+
+
+.. c:macro:: Py_RETURN_INF(sign)
+
+   Return :data:`math.inf` or :data:`-math.inf <math.inf>` from a function,
+   depending on the sign of *sign*.
+
+   On most platforms, this is equivalent to the following::
+
+      return PyFloat_FromDouble(copysign(INFINITY, sign));
+
+
 Pack and Unpack functions
 -------------------------