From 820be0b2ddd22ca65fb196a564d4f1c7d20bb657 Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Thu, 20 Nov 2025 08:42:01 -0500 Subject: [PATCH 1/2] gh-141004: Document `Py_MakePendingCalls` (GH-141137) (cherry picked from commit ce701032a3d5d3597466d5836ebe989db6eda2aa) Co-authored-by: Peter Bierma Co-authored-by: Victor Stinner --- Doc/c-api/init.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index c2026922c70368..e6dcb8a2601e01 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -1964,6 +1964,25 @@ pointer and a void pointer argument. This function now always schedules *func* to be run in the main interpreter. + +.. c:function:: int Py_MakePendingCalls(void) + + Execute all pending calls. This is usually executed automatically by the + interpreter. + + This function returns ``0`` on success, and returns ``-1`` with an exception + set on failure. + + If this is not called in the main thread of the main + interpreter, this function does nothing and returns ``0``. + The caller must hold an :term:`attached thread state`. + + .. versionadded:: 3.1 + + .. versionchanged:: 3.12 + This function only runs pending calls in the main interpreter. + + .. _profiling: Profiling and Tracing From 5ab588326661f6903aba1a0e3c666cef7945e130 Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Thu, 20 Nov 2025 09:24:45 -0500 Subject: [PATCH 2/2] Update Doc/c-api/init.rst --- Doc/c-api/init.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index e6dcb8a2601e01..a285c2467ae374 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -1975,7 +1975,7 @@ pointer and a void pointer argument. If this is not called in the main thread of the main interpreter, this function does nothing and returns ``0``. - The caller must hold an :term:`attached thread state`. + The caller must hold the :term:`GIL`. .. versionadded:: 3.1