[Python-checkins] bpo-40826: PyOS_InterruptOccurred() requires GIL (GH-20578)
Victor Stinner
webhook-mailer at python.org
Mon Jun 1 14:34:24 EDT 2020
https://github.com/python/cpython/commit/cbe129692293251e7fbcea9ff0d822824d90c140
commit: cbe129692293251e7fbcea9ff0d822824d90c140
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-06-01T20:34:15+02:00
summary:
bpo-40826: PyOS_InterruptOccurred() requires GIL (GH-20578)
PyOS_InterruptOccurred() now fails with a fatal error if it is called
with the GIL released.
files:
A Misc/NEWS.d/next/C API/2020-06-01-16-12-37.bpo-40826.zQzFoK.rst
M Modules/signalmodule.c
diff --git a/Misc/NEWS.d/next/C API/2020-06-01-16-12-37.bpo-40826.zQzFoK.rst b/Misc/NEWS.d/next/C API/2020-06-01-16-12-37.bpo-40826.zQzFoK.rst
new file mode 100644
index 0000000000000..0d7a36c3eb401
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2020-06-01-16-12-37.bpo-40826.zQzFoK.rst
@@ -0,0 +1,2 @@
+:c:func:`PyOS_InterruptOccurred` now fails with a fatal error if it is
+called with the GIL released.
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 8348971c353ba..6d340a68634af 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -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;
}
More information about the Python-checkins
mailing list