From cae4fe6010262496a693450aa9d52ace2d4ad479 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sun, 18 Oct 2009 14:01:08 +0200 Subject: [PATCH] Python calls SetTraceback() later, so should we --- Cython/Compiler/Nodes.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index c8deaf6b..7c68feea 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -5075,10 +5075,6 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; - value = tstate->curexc_value; - if (value && value != Py_None) { - PyException_SetTraceback(value, tb); - } Py_XDECREF(tmp_tb); } } @@ -5108,8 +5104,12 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) tstate->curexc_value = 0; tstate->curexc_traceback = 0; PyErr_NormalizeException(&local_type, &local_value, &local_tb); - if (tstate->curexc_type) + if (unlikely(tstate->curexc_type)) + goto bad; + #if PY_MAJOR_VERSION >= 3 + if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) goto bad; + #endif *type = local_type; *value = local_value; *tb = local_tb; @@ -5145,6 +5145,9 @@ bad: get_exception_tuple_utility_code = UtilityCode(proto=""" static PyObject *__Pyx_GetExceptionTuple(void); /*proto*/ """, +# I doubt that calling __Pyx_GetException() here is correct as it moves +# the exception from tstate->curexc_* to tstate->exc_*, which prevents +# exception handlers later on from receiving it. impl = """ static PyObject *__Pyx_GetExceptionTuple(void) { PyObject *type = NULL, *value = NULL, *tb = NULL; -- 2.26.2