mirror of
https://github.com/python/cpython.git
synced 2026-04-13 23:31:02 +00:00
gh-144748: Make PyErr_CheckSignals raise the exception scheduled by PyThreadState_SetAsyncExc (GH-145178)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
This commit is contained in:
parent
c9a5d9aae4
commit
3b276f3f59
13 changed files with 138 additions and 18 deletions
|
|
@ -1423,11 +1423,7 @@ _Py_HandlePending(PyThreadState *tstate)
|
|||
|
||||
/* Check for asynchronous exception. */
|
||||
if ((breaker & _PY_ASYNC_EXCEPTION_BIT) != 0) {
|
||||
_Py_unset_eval_breaker_bit(tstate, _PY_ASYNC_EXCEPTION_BIT);
|
||||
PyObject *exc = _Py_atomic_exchange_ptr(&tstate->async_exc, NULL);
|
||||
if (exc != NULL) {
|
||||
_PyErr_SetNone(tstate, exc);
|
||||
Py_DECREF(exc);
|
||||
if (_PyEval_RaiseAsyncExc(tstate) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1438,3 +1434,18 @@ _Py_HandlePending(PyThreadState *tstate)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_PyEval_RaiseAsyncExc(PyThreadState *tstate)
|
||||
{
|
||||
assert(tstate != NULL);
|
||||
assert(tstate == _PyThreadState_GET());
|
||||
_Py_unset_eval_breaker_bit(tstate, _PY_ASYNC_EXCEPTION_BIT);
|
||||
PyObject *exc = _Py_atomic_exchange_ptr(&tstate->async_exc, NULL);
|
||||
if (exc != NULL) {
|
||||
_PyErr_SetNone(tstate, exc);
|
||||
Py_DECREF(exc);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue