8000 bpo-40826: PyOS_InterruptOccurred() requires GIL (GH-20578) · python/cpython@cbe1296 · GitHub
[go: up one dir, main page]

Skip to content

Commit cbe1296

Browse files
authored
bpo-40826: PyOS_InterruptOccurred() requires GIL (GH-20578)
PyOS_InterruptOccurred() now fails with a fatal error if it is called with the GIL released.
1 parent 39de8e4 commit cbe1296

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:c:func:`PyOS_InterruptOccurred` now fails with a fatal error if it is
2+
called with the GIL released.

Modules/signalmodule.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,8 +1782,9 @@ PyOS_FiniInterrupts(void)
17821782
int
17831783
PyOS_InterruptOccurred(void)
17841784
{
1785-
PyInterpreterState *interp = _PyInterpreterState_GET();
1786-
if (!_Py_ThreadCanHandleSignals(interp)) {
1785+
PyThreadState *tstate = _PyThreadState_GET();
1786+
_Py_EnsureTstateNotNULL(tstate);
1787+
if (!_Py_ThreadCanHandleSignals(tstate->interp)) {
17871788
return 0;
17881789
}
17891790

0 commit comments

Comments
 (0)
0