From 106245fce041394707f8d8afdb503abd6cb67727 Mon Sep 17 00:00:00 2001 From: Mahmoud Soliman Date: Wed, 30 Oct 2019 02:30:13 +0200 Subject: [PATCH] Fixes #600 (Cython /python3.7 + compatibility) (#601) Signed-off-by: Benn Snyder --- wrappers/python/freenect.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/wrappers/python/freenect.c b/wrappers/python/freenect.c index f5738831..e248b672 100644 --- a/wrappers/python/freenect.c +++ b/wrappers/python/freenect.c @@ -11585,9 +11585,15 @@ static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_COMPILING_IN_CPYTHON PyThreadState *tstate = PyThreadState_GET(); + #if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 7 + *type = tstate->exc_state.exc_type; + *value = tstate->exc_state.exc_value; + *tb = tstate->exc_state.exc_traceback; + #else *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; + #endif Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); @@ -11599,12 +11605,23 @@ static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); + #if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 7 + tmp_type = tstate->exc_state.exc_type; + tmp_value = tstate->exc_state.exc_value; + tmp_tb = tstate->exc_state.exc_traceback; + tstate->exc_state.exc_type = type; + tstate->exc_state.exc_value = value; + tstate->exc_state.exc_traceback = tb; + #else 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; + #endif + + Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb);