From 5ef94d5f37fc313aa173d08fad81601bcfb2609e Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Tue, 4 Nov 2025 16:41:03 -0500 Subject: [PATCH 1/4] Document PyLong_FromPid and PyLong_AsPid --- Doc/c-api/long.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst index fcb20f7c93cbcc..402fc34ed04230 100644 --- a/Doc/c-api/long.rst +++ b/Doc/c-api/long.rst @@ -161,6 +161,15 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate. .. versionadded:: 3.13 +.. c:macro:: PyLong_FromPid(pid) + + Macro for creating a Python integer from a process ID. + + This can be defined as an alias to :c:func:`PyLong_FromLong` or + :c:func:`PyLong_FromLongLong`, depending on the size of the system's + PID type. + + .. c:function:: long PyLong_AsLong(PyObject *obj) .. index:: @@ -575,6 +584,15 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate. .. versionadded:: 3.13 +.. c:macro:: PyLong_AsPid(pid) + + Macro for converting a Python integer into a process ID. + + This can be defined as an alias to :c:func:`PyLong_AsLong`, + :c:func:`PyLong_FromLongLong`, or :c:func:`PyLong_AsInt`, depending on the + size of the system's PID type. + + .. c:function:: int PyLong_GetSign(PyObject *obj, int *sign) Get the sign of the integer object *obj*. From d9cff4b5d45e76f976f09d632c63140452980201 Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Thu, 6 Nov 2025 08:42:55 -0500 Subject: [PATCH 2/4] Update Doc/c-api/long.rst Co-authored-by: Victor Stinner --- Doc/c-api/long.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst index 402fc34ed04230..fdfcdac35f78fb 100644 --- a/Doc/c-api/long.rst +++ b/Doc/c-api/long.rst @@ -586,7 +586,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate. .. c:macro:: PyLong_AsPid(pid) - Macro for converting a Python integer into a process ID. + Macro for converting a Python integer into a process identifier. This can be defined as an alias to :c:func:`PyLong_AsLong`, :c:func:`PyLong_FromLongLong`, or :c:func:`PyLong_AsInt`, depending on the From 7fbbdcf057ec253d2f409f36688def475d4ee45a Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Thu, 6 Nov 2025 08:43:01 -0500 Subject: [PATCH 3/4] Update Doc/c-api/long.rst Co-authored-by: Victor Stinner --- Doc/c-api/long.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst index fdfcdac35f78fb..260d6ab5103371 100644 --- a/Doc/c-api/long.rst +++ b/Doc/c-api/long.rst @@ -163,7 +163,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate. .. c:macro:: PyLong_FromPid(pid) - Macro for creating a Python integer from a process ID. + Macro for creating a Python integer from a process identifier. This can be defined as an alias to :c:func:`PyLong_FromLong` or :c:func:`PyLong_FromLongLong`, depending on the size of the system's From 9cadc91889af43885e120e5ecfffc937173d423f Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Thu, 6 Nov 2025 08:43:57 -0500 Subject: [PATCH 4/4] Add versionadded notes. --- Doc/c-api/long.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst index 260d6ab5103371..ed34efe716d8b9 100644 --- a/Doc/c-api/long.rst +++ b/Doc/c-api/long.rst @@ -169,6 +169,8 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate. :c:func:`PyLong_FromLongLong`, depending on the size of the system's PID type. + .. versionadded:: 3.2 + .. c:function:: long PyLong_AsLong(PyObject *obj) @@ -592,6 +594,8 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate. :c:func:`PyLong_FromLongLong`, or :c:func:`PyLong_AsInt`, depending on the size of the system's PID type. + .. versionadded:: 3.2 + .. c:function:: int PyLong_GetSign(PyObject *obj, int *sign)