From: Vitja Makarov Date: Wed, 20 Apr 2011 12:48:15 +0000 (+0400) Subject: Add swap_exception_utility_code X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=f93648b5e6644a8b981b4aec78b719fa70a2c5e1;p=cython.git Add swap_exception_utility_code --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index e92e97dc..c0753e5c 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -6112,6 +6112,31 @@ static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) #------------------------------------------------------------------------------------ +swap_exception_utility_code = UtilityCode( +proto = """ +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ +""", +impl = """ +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyThreadState *tstate = PyThreadState_GET(); + + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + + tstate->exc_type = *type; + tstate->exc_value = *value; + tstate->exc_traceback = *tb; + + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} +""") + +#------------------------------------------------------------------------------------ + arg_type_test_utility_code = UtilityCode( proto = """ static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,