STINNER Victor added the comment:
Such function already exists in the master branch, but it's only part of the
internal C API:
PyAPI_FUNC(int) _PyOS_InterruptOccurred(PyThreadState *tstate);
Currently, the C API design is to always requires to hold the GIL.
--
_
New submission from Sebastian Berg :
In https://bugs.python.org/issue40826 it was defined that
`PyOS_InterruptOccurred()` can only be called with a GIL. NumPy had a few
places with very unsafe sigint handling (not thread-safe). But generally when
we are in a situation that catching sigints