diff options
author | Victor Stinner <vstinner@wyplay.com> | 2013-07-10 11:57:55 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@wyplay.com> | 2013-07-10 11:57:55 (GMT) |
commit | aaa8ed8b84c3c3fdf799e5c6aa538fbb54d6cb41 (patch) | |
tree | 41dd62a9ceaaae835b26ade71d16ab19277e9619 /Python/ceval.c | |
parent | 19361a2046c2f4006decf0e35265821dda2e78e7 (diff) | |
download | cpython-aaa8ed8b84c3c3fdf799e5c6aa538fbb54d6cb41.zip cpython-aaa8ed8b84c3c3fdf799e5c6aa538fbb54d6cb41.tar.gz cpython-aaa8ed8b84c3c3fdf799e5c6aa538fbb54d6cb41.tar.bz2 |
Issue #18408: Fix call_exc_trace(): if the traceback is NULL, use None when
building the tuple (type, value, traceback) passed to the callback.
PyTuple_Pack() does crash if an argument is NULL.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 82e85ca..8396f41 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3817,7 +3817,7 @@ prtrace(PyObject *v, char *str) static void call_exc_trace(Py_tracefunc func, PyObject *self, PyFrameObject *f) { - PyObject *type, *value, *traceback, *arg; + PyObject *type, *value, *traceback, *orig_traceback, *arg; int err; PyErr_Fetch(&type, &value, &traceback); if (value == NULL) { @@ -3825,6 +3825,11 @@ call_exc_trace(Py_tracefunc func, PyObject *self, PyFrameObject *f) Py_INCREF(value); } PyErr_NormalizeException(&type, &value, &traceback); + orig_traceback = traceback; + if (traceback == NULL) { + Py_INCREF(Py_None); + traceback = Py_None; + } arg = PyTuple_Pack(3, type, value, traceback); if (arg == NULL) { PyErr_Restore(type, value, traceback); @@ -3833,11 +3838,11 @@ call_exc_trace(Py_tracefunc func, PyObject *self, PyFrameObject *f) err = call_trace(func, self, f, PyTrace_EXCEPTION, arg); Py_DECREF(arg); if (err == 0) - PyErr_Restore(type, value, traceback); + PyErr_Restore(type, value, orig_traceback); else { Py_XDECREF(type); Py_XDECREF(value); - Py_XDECREF(traceback); + Py_XDECREF(orig_traceback); } } |