mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
bpo-31033: Improve the traceback for cancelled asyncio tasks (GH-19951)
When an asyncio.Task is cancelled, the exception traceback now starts with where the task was first interrupted. Previously, the traceback only had "depth one."
This commit is contained in:
parent
d17f3d8315
commit
da742ba826
10 changed files with 290 additions and 80 deletions
|
@ -512,6 +512,20 @@ _PyErr_ChainExceptions(PyObject *exc, PyObject *val, PyObject *tb)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
_PyErr_ChainStackItem(_PyErr_StackItem *exc_state)
|
||||
{
|
||||
if (exc_state->exc_type == NULL || exc_state->exc_type == Py_None) {
|
||||
return;
|
||||
}
|
||||
Py_INCREF(exc_state->exc_type);
|
||||
Py_XINCREF(exc_state->exc_value);
|
||||
Py_XINCREF(exc_state->exc_traceback);
|
||||
_PyErr_ChainExceptions(exc_state->exc_type,
|
||||
exc_state->exc_value,
|
||||
exc_state->exc_traceback);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_PyErr_FormatVFromCause(PyThreadState *tstate, PyObject *exception,
|
||||
const char *format, va_list vargs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue