From fd42c024ccde0eb068573c06b62aaeda72c9c2fa Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Fri, 14 Nov 2025 11:20:36 +0000 Subject: [PATCH 1/2] gh-141004: Document `PyOS_InterruptOccurred` (GH-141526) (cherry picked from commit ef90261be508b97d682589aac8f00065a9585683) Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Doc/c-api/sys.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Doc/c-api/sys.rst b/Doc/c-api/sys.rst index c688afdca8231d..0089479677133c 100644 --- a/Doc/c-api/sys.rst +++ b/Doc/c-api/sys.rst @@ -123,6 +123,24 @@ Operating System Utilities This is a thin wrapper around either :c:func:`!sigaction` or :c:func:`!signal`. Do not call those functions directly! + +.. c:function:: int PyOS_InterruptOccurred(void) + + Check if a :c:macro:`!SIGINT` signal has been received. + + Returns ``1`` if a :c:macro:`!SIGINT` has occurred and clears the signal flag, + or ``0`` otherwise. + + In most cases, you should prefer :c:func:`PyErr_CheckSignals` over this function. + :c:func:`!PyErr_CheckSignals` invokes the appropriate signal handlers + for all pending signals, allowing Python code to handle the signal properly. + This function only detects :c:macro:`!SIGINT` and does not invoke any Python + signal handlers. + + This function is async-signal-safe and this function cannot fail. + The caller must hold an :term:`attached thread state`. + + .. c:function:: wchar_t* Py_DecodeLocale(const char* arg, size_t *size) .. warning:: From 58b67315fa54c5e6a11cae3f927c6ceda06b982d Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Fri, 14 Nov 2025 15:51:14 +0000 Subject: [PATCH 2/2] Remove link to term not present in 3.13 glossary --- Doc/c-api/sys.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/sys.rst b/Doc/c-api/sys.rst index 0089479677133c..8fb30a7826d84a 100644 --- a/Doc/c-api/sys.rst +++ b/Doc/c-api/sys.rst @@ -138,7 +138,7 @@ Operating System Utilities signal handlers. This function is async-signal-safe and this function cannot fail. - The caller must hold an :term:`attached thread state`. + The caller must hold an attached thread state. .. c:function:: wchar_t* Py_DecodeLocale(const char* arg, size_t *size)