From: Stefan Behnel Date: Sun, 18 Oct 2009 12:01:08 +0000 (+0200) Subject: Python calls SetTraceback() later, so should we X-Git-Tag: 0.13.beta0~2^2~121^2~17 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cae4fe6010262496a693450aa9d52ace2d4ad479;p=cython.git Python calls SetTraceback() later, so should we --- 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;