mirror of
https://github.com/python/cpython
synced 2024-09-05 00:05:39 +00:00
bpo-45711: Use _PyErr_ClearExcState instead of setting only exc_value to NULL (GH-29404)
This commit is contained in:
parent
76d14fac72
commit
05fbd60147
|
@ -1371,10 +1371,15 @@ _asyncio_Future__make_cancelled_error_impl(FutureObj *self)
|
||||||
{
|
{
|
||||||
PyObject *exc = create_cancelled_error(self->fut_cancel_msg);
|
PyObject *exc = create_cancelled_error(self->fut_cancel_msg);
|
||||||
_PyErr_StackItem *exc_state = &self->fut_cancelled_exc_state;
|
_PyErr_StackItem *exc_state = &self->fut_cancelled_exc_state;
|
||||||
/* Transfer ownership of exc_value from exc_state to exc since we are
|
|
||||||
done with it. */
|
if (exc_state->exc_value) {
|
||||||
PyException_SetContext(exc, exc_state->exc_value);
|
PyException_SetContext(exc, Py_NewRef(exc_state->exc_value));
|
||||||
exc_state->exc_value = NULL;
|
_PyErr_ClearExcState(exc_state);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert(exc_state->exc_type == NULL);
|
||||||
|
assert(exc_state->exc_traceback == NULL);
|
||||||
|
}
|
||||||
|
|
||||||
return exc;
|
return exc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue