summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2020-05-18 05:47:31 (GMT)
committerGitHub <noreply@github.com>2020-05-18 05:47:31 (GMT)
commitda742ba826721da84140abc785856d4ccc2d787f (patch)
tree1a6f9db52fe93edf9946620d0e2312e97c6f16a0 /Python
parentd17f3d8315a3a775ab0807fc80acf92b1bd682f8 (diff)
downloadcpython-da742ba826721da84140abc785856d4ccc2d787f.zip
cpython-da742ba826721da84140abc785856d4ccc2d787f.tar.gz
cpython-da742ba826721da84140abc785856d4ccc2d787f.tar.bz2
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."
Diffstat (limited to 'Python')
-rw-r--r--Python/errors.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/Python/errors.c b/Python/errors.c
index f856a79..3b42c11 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -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)