summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2023-02-13 09:05:22 +0100
committerStefan Behnel <stefan_ml@behnel.de>2023-02-13 09:08:40 +0100
commit1dba3d3b44ce942dafe4c77dec4c64def22c57e1 (patch)
treeec2670a361f37b0ab46269d1963dacf429285782
parentb24286d35aaaf1318cd2bebb10e3e16d72965a5b (diff)
downloadcython-1dba3d3b44ce942dafe4c77dec4c64def22c57e1.tar.gz
Use a more correct and specific CPython internals guard in __Pyx_Raise().
See https://github.com/cython/cython/issues/5238#issuecomment-1426853108
-rw-r--r--Cython/Utility/Exceptions.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/Cython/Utility/Exceptions.c b/Cython/Utility/Exceptions.c
index 3c9784f88..cf3209204 100644
--- a/Cython/Utility/Exceptions.c
+++ b/Cython/Utility/Exceptions.c
@@ -301,13 +301,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject
PyErr_SetObject(type, value);
if (tb) {
-#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API
- 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) {
@@ -315,6 +309,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
}