diff options
author | Victor Stinner <vstinner@python.org> | 2020-06-03 12:39:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-03 12:39:59 (GMT) |
commit | fa7ab6aa0f9a4f695e5525db5a113cd21fa93787 (patch) | |
tree | db9c9a9fc6908662ed752d6617a719cc566f155f /Modules/signalmodule.c | |
parent | 18a90248fdd92b27098cc4db773686a2d10a4d24 (diff) | |
download | cpython-fa7ab6aa0f9a4f695e5525db5a113cd21fa93787.zip cpython-fa7ab6aa0f9a4f695e5525db5a113cd21fa93787.tar.gz cpython-fa7ab6aa0f9a4f695e5525db5a113cd21fa93787.tar.bz2 |
bpo-40826: Add _PyOS_InterruptOccurred(tstate) function (GH-20599)
my_fgets() now calls _PyOS_InterruptOccurred(tstate) to check for
pending signals, rather calling PyOS_InterruptOccurred().
my_fgets() is called with the GIL released, whereas
PyOS_InterruptOccurred() must be called with the GIL held.
test_repl: use text=True and avoid SuppressCrashReport in
test_multiline_string_parsing().
Fix my_fgets() on Windows: fgets(fp) does crash if fileno(fp) is closed.
Diffstat (limited to 'Modules/signalmodule.c')
-rw-r--r-- | Modules/signalmodule.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index 24dbd42..ef3536a 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -1779,10 +1779,11 @@ PyOS_FiniInterrupts(void) finisignal(); } + +// The caller doesn't have to hold the GIL int -PyOS_InterruptOccurred(void) +_PyOS_InterruptOccurred(PyThreadState *tstate) { - PyThreadState *tstate = _PyThreadState_GET(); _Py_EnsureTstateNotNULL(tstate); if (!_Py_ThreadCanHandleSignals(tstate->interp)) { return 0; @@ -1797,6 +1798,15 @@ PyOS_InterruptOccurred(void) } +// The caller must to hold the GIL +int +PyOS_InterruptOccurred(void) +{ + PyThreadState *tstate = _PyThreadState_GET(); + return _PyOS_InterruptOccurred(tstate); +} + + #ifdef HAVE_FORK static void _clear_pending_signals(void) |