mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
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.
This commit is contained in:
parent
18a90248fd
commit
fa7ab6aa0f
5 changed files with 46 additions and 13 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue