bpo-40826: PyOS_InterruptOccurred() requires GIL (GH-20578)

PyOS_InterruptOccurred() now fails with a fatal error if it is called
with the GIL released.
This commit is contained in:
Victor Stinner 2020-06-01 20:34:15 +02:00 committed by GitHub
parent 39de8e4b6f
commit cbe1296922
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -0,0 +1,2 @@
:c:func:`PyOS_InterruptOccurred` now fails with a fatal error if it is
called with the GIL released.

View File

@ -1782,8 +1782,9 @@ PyOS_FiniInterrupts(void)
int
PyOS_InterruptOccurred(void)
{
PyInterpreterState *interp = _PyInterpreterState_GET();
if (!_Py_ThreadCanHandleSignals(interp)) {
PyThreadState *tstate = _PyThreadState_GET();
_Py_EnsureTstateNotNULL(tstate);
if (!_Py_ThreadCanHandleSignals(tstate->interp)) {
return 0;
}