From f93648b5e6644a8b981b4aec78b719fa70a2c5e1 Mon Sep 17 00:00:00 2001 From: Vitja Makarov Date: Wed, 20 Apr 2011 16:48:15 +0400 Subject: [PATCH] Add swap_exception_utility_code --- Cython/Compiler/Nodes.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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, -- 2.26.2