diff options
author | Tomáš Hrnčiar <tomas.hrnciar@me.com> | 2023-03-22 09:18:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-22 09:18:06 +0100 |
commit | 6af714dbd3338d8a77a4db9d88d8504fb67a188c (patch) | |
tree | 86b58835da266ee6007c6bac77dce36c58233ad6 | |
parent | 21e64ec20619d9ac530030a8e0c259912af10407 (diff) | |
download | cython-6af714dbd3338d8a77a4db9d88d8504fb67a188c.tar.gz |
Use a more correct and specific CPython internals guard in __Pyx_Raise(). (GH-5330)
This is a backport of https://github.com/cython/cython/commit/1dba3d3b44ce942dafe4c77dec4c64def22c57e1 from Cython's master branch.
See https://github.com/cython/cython/issues/5238#issuecomment-1426853108
-rw-r--r-- | Cython/Utility/Exceptions.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Cython/Utility/Exceptions.c b/Cython/Utility/Exceptions.c index 2c87f720c..87d3a5cdd 100644 --- a/Cython/Utility/Exceptions.c +++ b/Cython/Utility/Exceptions.c @@ -284,13 +284,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject PyErr_SetObject(type, value); if (tb) { -#if CYTHON_COMPILING_IN_PYPY - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); - Py_INCREF(tb); - PyErr_Restore(tmp_type, tmp_value, tb); - Py_XDECREF(tmp_tb); -#else +#if CYTHON_FAST_THREAD_STATE PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { @@ -298,6 +292,12 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } +#else + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); + Py_INCREF(tb); + PyErr_Restore(tmp_type, tmp_value, tb); + Py_XDECREF(tmp_tb); #endif } |