mirror of
https://abf.rosa.ru/djam/python-cython.git
synced 2025-02-23 22:02:47 +00:00
add patch for fix https://github.com/cython/cython/issues/4500
This commit is contained in:
parent
40e1e12e42
commit
f1eada201c
2 changed files with 327 additions and 1 deletions
325
cython-CPython-3.11a4.patch
Normal file
325
cython-CPython-3.11a4.patch
Normal file
|
@ -0,0 +1,325 @@
|
|||
# from https://github.com/cython/cython/pull/4584
|
||||
|
||||
diff -ruN a/Cython/Utility/Coroutine.c b/Cython/Utility/Coroutine.c
|
||||
--- a/Cython/Utility/Coroutine.c 2023-04-02 19:39:29.000000000 +0900
|
||||
+++ b/Cython/Utility/Coroutine.c 2023-04-18 11:32:47.352800662 +0900
|
||||
@@ -601,6 +601,9 @@
|
||||
|
||||
static CYTHON_INLINE
|
||||
void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
|
||||
+#if PY_VERSION_HEX >= 0x030B00a4
|
||||
+ Py_CLEAR(exc_state->exc_value);
|
||||
+#else
|
||||
PyObject *t, *v, *tb;
|
||||
t = exc_state->exc_type;
|
||||
v = exc_state->exc_value;
|
||||
@@ -613,6 +616,7 @@
|
||||
Py_XDECREF(t);
|
||||
Py_XDECREF(v);
|
||||
Py_XDECREF(tb);
|
||||
+#endif
|
||||
}
|
||||
|
||||
#define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
|
||||
@@ -714,14 +718,21 @@
|
||||
// - do not touch external frames and tracebacks
|
||||
|
||||
exc_state = &self->gi_exc_state;
|
||||
- if (exc_state->exc_type) {
|
||||
+ if (exc_state->exc_value) {
|
||||
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
|
||||
// FIXME: what to do in PyPy?
|
||||
#else
|
||||
// Generators always return to their most recent caller, not
|
||||
// necessarily their creator.
|
||||
- if (exc_state->exc_traceback) {
|
||||
- PyTracebackObject *tb = (PyTracebackObject *) exc_state->exc_traceback;
|
||||
+ PyObject *exc_tb;
|
||||
+ #if PY_VERSION_HEX >= 0x030B00a4
|
||||
+ // owned reference!
|
||||
+ exc_tb = PyException_GetTraceback(exc_state->exc_value);
|
||||
+ #else
|
||||
+ exc_tb = exc_state->exc_traceback;
|
||||
+ #endif
|
||||
+ if (exc_tb) {
|
||||
+ PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
|
||||
PyFrameObject *f = tb->tb_frame;
|
||||
|
||||
assert(f->f_back == NULL);
|
||||
@@ -733,6 +744,9 @@
|
||||
Py_XINCREF(tstate->frame);
|
||||
f->f_back = tstate->frame;
|
||||
#endif
|
||||
+ #if PY_VERSION_HEX >= 0x030B00a4
|
||||
+ Py_DECREF(exc_tb);
|
||||
+ #endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -774,17 +788,28 @@
|
||||
// Don't keep the reference to f_back any longer than necessary. It
|
||||
// may keep a chain of frames alive or it could create a reference
|
||||
// cycle.
|
||||
- PyObject *exc_tb = exc_state->exc_traceback;
|
||||
-
|
||||
- if (likely(exc_tb)) {
|
||||
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
|
||||
// FIXME: what to do in PyPy?
|
||||
#else
|
||||
+ PyObject *exc_tb;
|
||||
+
|
||||
+ #if PY_VERSION_HEX >= 0x030B00a4
|
||||
+ if (!exc_state->exc_value) return;
|
||||
+ // owned reference!
|
||||
+ exc_tb = PyException_GetTraceback(exc_state->exc_value);
|
||||
+ #else
|
||||
+ exc_tb = exc_state->exc_traceback;
|
||||
+ #endif
|
||||
+
|
||||
+ if (likely(exc_tb)) {
|
||||
PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
|
||||
PyFrameObject *f = tb->tb_frame;
|
||||
Py_CLEAR(f->f_back);
|
||||
-#endif
|
||||
+ #if PY_VERSION_HEX >= 0x030B00a4
|
||||
+ Py_DECREF(exc_tb);
|
||||
+ #endif
|
||||
}
|
||||
+#endif
|
||||
}
|
||||
|
||||
static CYTHON_INLINE
|
||||
@@ -1128,9 +1153,13 @@
|
||||
}
|
||||
|
||||
static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) {
|
||||
+#if PY_VERSION_HEX >= 0x030B00a4
|
||||
+ Py_VISIT(exc_state->exc_value);
|
||||
+#else
|
||||
Py_VISIT(exc_state->exc_type);
|
||||
Py_VISIT(exc_state->exc_value);
|
||||
Py_VISIT(exc_state->exc_traceback);
|
||||
+#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1431,9 +1460,13 @@
|
||||
gen->resume_label = 0;
|
||||
gen->classobj = NULL;
|
||||
gen->yieldfrom = NULL;
|
||||
+ #if PY_VERSION_HEX >= 0x030B00a4
|
||||
+ gen->gi_exc_state.exc_value = NULL;
|
||||
+ #else
|
||||
gen->gi_exc_state.exc_type = NULL;
|
||||
gen->gi_exc_state.exc_value = NULL;
|
||||
gen->gi_exc_state.exc_traceback = NULL;
|
||||
+ #endif
|
||||
#if CYTHON_USE_EXC_INFO_STACK
|
||||
gen->gi_exc_state.previous_item = NULL;
|
||||
#endif
|
||||
@@ -2017,7 +2050,7 @@
|
||||
#if CYTHON_FAST_THREAD_STATE
|
||||
__Pyx_PyThreadState_assign
|
||||
#if CYTHON_USE_EXC_INFO_STACK
|
||||
- if (!$local_tstate_cname->exc_info->exc_type)
|
||||
+ if (!$local_tstate_cname->exc_info->exc_value)
|
||||
#else
|
||||
if (!$local_tstate_cname->exc_type)
|
||||
#endif
|
||||
diff -ruN a/Cython/Utility/Exceptions.c b/Cython/Utility/Exceptions.c
|
||||
--- a/Cython/Utility/Exceptions.c 2023-04-02 19:39:29.000000000 +0900
|
||||
+++ b/Cython/Utility/Exceptions.c 2023-04-18 11:42:28.014745170 +0900
|
||||
@@ -322,7 +322,7 @@
|
||||
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
|
||||
{
|
||||
_PyErr_StackItem *exc_info = tstate->exc_info;
|
||||
- while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
|
||||
+ while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) &&
|
||||
exc_info->previous_item != NULL)
|
||||
{
|
||||
exc_info = exc_info->previous_item;
|
||||
@@ -388,12 +388,21 @@
|
||||
#if CYTHON_USE_EXC_INFO_STACK
|
||||
{
|
||||
_PyErr_StackItem *exc_info = tstate->exc_info;
|
||||
+ #if PY_VERSION_HEX >= 0x030B00a4
|
||||
+ tmp_value = exc_info->exc_value;
|
||||
+ exc_info->exc_value = local_value;
|
||||
+ tmp_type = NULL;
|
||||
+ tmp_tb = NULL;
|
||||
+ Py_XDECREF(local_type);
|
||||
+ Py_XDECREF(local_tb);
|
||||
+ #else
|
||||
tmp_type = exc_info->exc_type;
|
||||
tmp_value = exc_info->exc_value;
|
||||
tmp_tb = exc_info->exc_traceback;
|
||||
exc_info->exc_type = local_type;
|
||||
exc_info->exc_value = local_value;
|
||||
exc_info->exc_traceback = local_tb;
|
||||
+ #endif
|
||||
}
|
||||
#else
|
||||
tmp_type = tstate->exc_type;
|
||||
@@ -433,35 +442,44 @@
|
||||
PyObject *type = NULL, *value = NULL, *tb = NULL;
|
||||
#if CYTHON_FAST_THREAD_STATE
|
||||
PyThreadState *tstate = PyThreadState_GET();
|
||||
- #if CYTHON_USE_EXC_INFO_STACK
|
||||
+ #if CYTHON_USE_EXC_INFO_STACK
|
||||
_PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
|
||||
- type = exc_info->exc_type;
|
||||
value = exc_info->exc_value;
|
||||
- tb = exc_info->exc_traceback;
|
||||
+ #if PY_VERSION_HEX >= 0x030B00a4
|
||||
+ if (unlikely(value == Py_None)) {
|
||||
+ value = NULL;
|
||||
+ } else if (value) {
|
||||
+ Py_INCREF(value);
|
||||
+ type = (PyObject*) Py_TYPE(value);
|
||||
+ Py_INCREF(type);
|
||||
+ tb = PyException_GetTraceback(value);
|
||||
+ }
|
||||
#else
|
||||
+ type = exc_info->exc_type;
|
||||
+ tb = exc_info->exc_traceback;
|
||||
+ Py_XINCREF(type);
|
||||
+ Py_XINCREF(value);
|
||||
+ Py_XINCREF(tb);
|
||||
+ #endif
|
||||
+ #else
|
||||
type = tstate->exc_type;
|
||||
value = tstate->exc_value;
|
||||
tb = tstate->exc_traceback;
|
||||
- #endif
|
||||
+ Py_XINCREF(type);
|
||||
+ Py_XINCREF(value);
|
||||
+ Py_XINCREF(tb);
|
||||
+ #endif
|
||||
#else
|
||||
PyErr_GetExcInfo(&type, &value, &tb);
|
||||
#endif
|
||||
- if (!type || type == Py_None) {
|
||||
-#if !CYTHON_FAST_THREAD_STATE
|
||||
+ if (unlikely(!type || type == Py_None)) {
|
||||
Py_XDECREF(type);
|
||||
Py_XDECREF(value);
|
||||
Py_XDECREF(tb);
|
||||
-#endif
|
||||
// message copied from Py3
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"No active exception to reraise");
|
||||
} else {
|
||||
-#if CYTHON_FAST_THREAD_STATE
|
||||
- Py_INCREF(type);
|
||||
- Py_XINCREF(value);
|
||||
- Py_XINCREF(tb);
|
||||
-
|
||||
-#endif
|
||||
PyErr_Restore(type, value, tb);
|
||||
}
|
||||
}
|
||||
@@ -487,24 +505,49 @@
|
||||
|
||||
#if CYTHON_FAST_THREAD_STATE
|
||||
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
|
||||
- #if CYTHON_USE_EXC_INFO_STACK
|
||||
+ #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
|
||||
_PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
|
||||
+ PyObject *exc_value = exc_info->exc_value;
|
||||
+ if (exc_value == NULL || exc_value == Py_None) {
|
||||
+ *value = NULL;
|
||||
+ *type = NULL;
|
||||
+ *tb = NULL;
|
||||
+ } else {
|
||||
+ *value = exc_value;
|
||||
+ Py_INCREF(*value);
|
||||
+ *type = (PyObject*) Py_TYPE(exc_value);
|
||||
+ Py_INCREF(*type);
|
||||
+ *tb = PyException_GetTraceback(exc_value);
|
||||
+ }
|
||||
+ #elif CYTHON_USE_EXC_INFO_STACK
|
||||
+ _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
|
||||
*type = exc_info->exc_type;
|
||||
*value = exc_info->exc_value;
|
||||
*tb = exc_info->exc_traceback;
|
||||
- #else
|
||||
+ Py_XINCREF(*type);
|
||||
+ Py_XINCREF(*value);
|
||||
+ Py_XINCREF(*tb);
|
||||
+ #else
|
||||
*type = tstate->exc_type;
|
||||
*value = tstate->exc_value;
|
||||
*tb = tstate->exc_traceback;
|
||||
- #endif
|
||||
Py_XINCREF(*type);
|
||||
Py_XINCREF(*value);
|
||||
Py_XINCREF(*tb);
|
||||
+ #endif
|
||||
}
|
||||
|
||||
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
|
||||
+ #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
|
||||
+ _PyErr_StackItem *exc_info = tstate->exc_info;
|
||||
+ PyObject *tmp_value = exc_info->exc_value;
|
||||
+ exc_info->exc_value = value;
|
||||
+ Py_XDECREF(tmp_value);
|
||||
+ // TODO: avoid passing these at all
|
||||
+ Py_XDECREF(type);
|
||||
+ Py_XDECREF(tb);
|
||||
+ #else
|
||||
PyObject *tmp_type, *tmp_value, *tmp_tb;
|
||||
-
|
||||
#if CYTHON_USE_EXC_INFO_STACK
|
||||
_PyErr_StackItem *exc_info = tstate->exc_info;
|
||||
tmp_type = exc_info->exc_type;
|
||||
@@ -524,6 +567,7 @@
|
||||
Py_XDECREF(tmp_type);
|
||||
Py_XDECREF(tmp_value);
|
||||
Py_XDECREF(tmp_tb);
|
||||
+ #endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -543,8 +587,22 @@
|
||||
#if CYTHON_FAST_THREAD_STATE
|
||||
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
|
||||
PyObject *tmp_type, *tmp_value, *tmp_tb;
|
||||
-
|
||||
- #if CYTHON_USE_EXC_INFO_STACK
|
||||
+ #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
|
||||
+ _PyErr_StackItem *exc_info = tstate->exc_info;
|
||||
+ tmp_value = exc_info->exc_value;
|
||||
+ exc_info->exc_value = *value;
|
||||
+ if (tmp_value == NULL || tmp_value == Py_None) {
|
||||
+ Py_XDECREF(tmp_value);
|
||||
+ tmp_value = NULL;
|
||||
+ tmp_type = NULL;
|
||||
+ tmp_tb = NULL;
|
||||
+ } else {
|
||||
+ // TODO: avoid swapping these at all
|
||||
+ tmp_type = (PyObject*) Py_TYPE(tmp_value);
|
||||
+ Py_INCREF(tmp_type);
|
||||
+ tmp_tb = PyException_GetTraceback(tmp_value);
|
||||
+ }
|
||||
+ #elif CYTHON_USE_EXC_INFO_STACK
|
||||
_PyErr_StackItem *exc_info = tstate->exc_info;
|
||||
tmp_type = exc_info->exc_type;
|
||||
tmp_value = exc_info->exc_value;
|
||||
@@ -553,7 +611,7 @@
|
||||
exc_info->exc_type = *type;
|
||||
exc_info->exc_value = *value;
|
||||
exc_info->exc_traceback = *tb;
|
||||
- #else
|
||||
+ #else
|
||||
tmp_type = tstate->exc_type;
|
||||
tmp_value = tstate->exc_value;
|
||||
tmp_tb = tstate->exc_traceback;
|
||||
@@ -561,7 +619,7 @@
|
||||
tstate->exc_type = *type;
|
||||
tstate->exc_value = *value;
|
||||
tstate->exc_traceback = *tb;
|
||||
- #endif
|
||||
+ #endif
|
||||
|
||||
*type = tmp_type;
|
||||
*value = tmp_value;
|
|
@ -11,13 +11,14 @@
|
|||
Summary: Language for writing C extensions to Python
|
||||
Name: python-cython
|
||||
Version: 0.29.34
|
||||
Release: 1
|
||||
Release: 2
|
||||
License: Python
|
||||
Group: Development/Python
|
||||
Url: http://www.cython.org
|
||||
Source0: https://github.com/cython/cython/archive/%{version}.tar.gz?/cython-%{version}.tar.gz
|
||||
Source1: %{name}.rpmlintrc
|
||||
Patch0: cython-0.29.28-missing-header.patch
|
||||
Patch1: cython-CPython-3.11a4.patch
|
||||
BuildRequires: dos2unix
|
||||
%if %{with check}
|
||||
BuildRequires: gdb
|
||||
|
|
Loading…
Add table
Reference in a new issue