14
0

- Add py313.patch to adapt Cython0 to Python 3.13

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Cython0?expand=0&rev=10
This commit is contained in:
2024-10-21 13:23:04 +00:00
committed by Git OBS Bridge
commit 0939032a55
7 changed files with 2503 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.osc

BIN
Cython-0.29.37.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

535
py313.patch Normal file
View File

@@ -0,0 +1,535 @@
Index: Cython-0.29.37/Cython/Compiler/ModuleNode.py
===================================================================
--- Cython-0.29.37.orig/Cython/Compiler/ModuleNode.py
+++ Cython-0.29.37/Cython/Compiler/ModuleNode.py
@@ -2825,15 +2825,13 @@ class ModuleNode(Nodes.Node, Nodes.Block
code.put_incref(env.module_dict_cname, py_object_type, nanny=False)
code.putln(
- '%s = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); %s' % (
+ '%s = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); %s' % (
Naming.builtins_cname,
code.error_goto_if_null(Naming.builtins_cname, self.pos)))
- code.put_incref(Naming.builtins_cname, py_object_type, nanny=False)
code.putln(
- '%s = PyImport_AddModule((char *) "cython_runtime"); %s' % (
+ '%s = __Pyx_PyImport_AddModuleRef((const char *) "cython_runtime"); %s' % (
Naming.cython_runtime_cname,
code.error_goto_if_null(Naming.cython_runtime_cname, self.pos)))
- code.put_incref(Naming.cython_runtime_cname, py_object_type, nanny=False)
code.putln(
'if (PyObject_SetAttrString(%s, "__builtins__", %s) < 0) %s' % (
env.module_cname,
@@ -2841,11 +2839,10 @@ class ModuleNode(Nodes.Node, Nodes.Block
code.error_goto(self.pos)))
if Options.pre_import is not None:
code.putln(
- '%s = PyImport_AddModule("%s"); %s' % (
+ '%s = __Pyx_PyImport_AddModuleRef("%s"); %s' % (
Naming.preimport_cname,
Options.pre_import,
code.error_goto_if_null(Naming.preimport_cname, self.pos)))
- code.put_incref(Naming.preimport_cname, py_object_type, nanny=False)
def generate_global_init_code(self, env, code):
# Generate code to initialise global PyObject *
Index: Cython-0.29.37/Cython/Utility/Builtins.c
===================================================================
--- Cython-0.29.37.orig/Cython/Utility/Builtins.c
+++ Cython-0.29.37/Cython/Utility/Builtins.c
@@ -175,6 +175,7 @@ static CYTHON_INLINE PyObject *__Pyx_Get
//@requires: Exceptions.c::PyErrFetchRestore
//@requires: Exceptions.c::PyErrExceptionMatches
+#if __PYX_LIMITED_VERSION_HEX < 0x030d00A1
static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
@@ -184,19 +185,31 @@ static PyObject *__Pyx_GetAttr3Default(P
Py_INCREF(d);
return d;
}
+#endif
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
PyObject *r = __Pyx_GetAttr(o, n);
+#if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1
+ int res = PyObject_GetOptionalAttr(o, n, &r);
+ // On failure (res == -1), r is set to NULL.
+ return (res != 0) ? r : __Pyx_NewRef(d);
+#else
return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
+#endif
}
//////////////////// HasAttr.proto ////////////////////
+#if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1
+#define __Pyx_HasAttr(o, n) PyObject_HasAttrWithError(o, n)
+#else
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *); /*proto*/
+#endif
//////////////////// HasAttr ////////////////////
//@requires: ObjectHandling.c::GetAttr
+#if __PYX_LIMITED_VERSION_HEX < 0x030d00A1
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
PyObject *r;
if (unlikely(!__Pyx_PyBaseString_Check(n))) {
@@ -213,6 +226,7 @@ static CYTHON_INLINE int __Pyx_HasAttr(P
return 1;
}
}
+#endif
//////////////////// Intern.proto ////////////////////
@@ -278,7 +292,7 @@ static PyObject *__Pyx_PyLong_AbsNeg(PyO
// digits are unsigned
return PyLong_FromLong(((PyLongObject*)n)->ob_digit[0]);
}
-#if CYTHON_COMPILING_IN_CPYTHON
+#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000
{
PyObject *copy = _PyLong_Copy((PyLongObject*)n);
if (likely(copy)) {
Index: Cython-0.29.37/Cython/Utility/Coroutine.c
===================================================================
--- Cython-0.29.37.orig/Cython/Utility/Coroutine.c
+++ Cython-0.29.37/Cython/Utility/Coroutine.c
@@ -135,7 +135,7 @@ static CYTHON_INLINE PyObject *__Pyx_Cor
static void __Pyx_Coroutine_AwaitableIterError(PyObject *source) {
-#if PY_VERSION_HEX >= 0x030600B3 || defined(_PyErr_FormatFromCause)
+#if PY_VERSION_HEX >= 0x030600B3 && PY_VERSION_HEX < 0x030d0000 || defined(_PyErr_FormatFromCause)
_PyErr_FormatFromCause(
PyExc_TypeError,
"'async for' received an invalid object "
@@ -166,7 +166,7 @@ static void __Pyx_Coroutine_AwaitableIte
PyErr_Restore(exc, val2, tb);
#else
// since Py2 does not have exception chaining, it's better to avoid shadowing exceptions there
- source++;
+ CYTHON_UNUSED_VAR(source);
#endif
}
@@ -489,6 +489,7 @@ static int __pyx_Generator_init(void); /
//@requires: Exceptions.c::RaiseException
//@requires: Exceptions.c::SaveResetException
//@requires: ObjectHandling.c::PyObjectCallMethod1
+//@requires: ObjectHandling.c::PyObjectCallOneArg
//@requires: ObjectHandling.c::PyObjectGetAttrStr
//@requires: CommonStructures.c::FetchCommonType
@@ -822,9 +823,23 @@ PyObject *__Pyx_PyGen_Send(PyGenObject *
PyErr_SetNone(PyExc_StopIteration);
}
else {
+#if PY_VERSION_HEX < 0x030d00A1
_PyGen_SetStopIterationValue(result);
+#else
+ if (!PyTuple_Check(result) && !PyExceptionInstance_Check(result)) {
+ // delay instantiation if possible
+ PyErr_SetObject(PyExc_StopIteration, result);
+ } else {
+ PyObject *exc = __Pyx_PyObject_CallOneArg(PyExc_StopIteration, result);
+ if (likely(exc != NULL)) {
+ PyErr_SetObject(PyExc_StopIteration, exc);
+ Py_DECREF(exc);
+ }
+ }
+#endif
}
- Py_CLEAR(result);
+ Py_DECREF(result);
+ result = NULL;
}
return result;
#endif
Index: Cython-0.29.37/Cython/Utility/Exceptions.c
===================================================================
--- Cython-0.29.37.orig/Cython/Utility/Exceptions.c
+++ Cython-0.29.37/Cython/Utility/Exceptions.c
@@ -17,7 +17,7 @@ __Pyx_init_assertions_enabled();
#define __pyx_assertions_enabled() (1)
#elif PY_VERSION_HEX < 0x03080000 || CYTHON_COMPILING_IN_PYPY || defined(Py_LIMITED_API)
#define __pyx_assertions_enabled() (!Py_OptimizeFlag)
-#elif CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030900A6
+#elif CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030900A6 && PY_VERSION_HEX < 0x030d0000
// Py3.8+ has PyConfig from PEP 587, but only Py3.9 added read access to it.
// Py_OptimizeFlag is deprecated in Py3.12+
static int __pyx_assertions_enabled_flag;
@@ -401,6 +401,8 @@ static int __Pyx_GetException(PyObject *
if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
goto bad;
}
+ #else
+ return NULL;
#endif
// traceback may be NULL for freshly raised exceptions
Py_XINCREF(local_tb);
Index: Cython-0.29.37/Cython/Utility/ImportExport.c
===================================================================
--- Cython-0.29.37.orig/Cython/Utility/ImportExport.c
+++ Cython-0.29.37/Cython/Utility/ImportExport.c
@@ -233,7 +233,6 @@ static int __Pyx_SetPackagePathFromImpor
#endif
/////////////// SetPackagePathFromImportLib ///////////////
-//@requires: ObjectHandling.c::PyObjectGetAttrStr
//@substitute: naming
// PY_VERSION_HEX >= 0x03030000
Index: Cython-0.29.37/Cython/Utility/ModuleSetupCode.c
===================================================================
--- Cython-0.29.37.orig/Cython/Utility/ModuleSetupCode.c
+++ Cython-0.29.37/Cython/Utility/ModuleSetupCode.c
@@ -604,6 +604,10 @@ class __Pyx_FakeReference {
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
#define __Pyx_PyThreadState_Current PyThreadState_GET()
+#elif PY_VERSION_HEX >= 0x030d00A1
+ //#elif PY_VERSION_HEX >= 0x03050200
+ // Actually added in 3.5.2, but compiling against that does not guarantee that we get imported there.
+ #define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked()
#elif PY_VERSION_HEX >= 0x03060000
//#elif PY_VERSION_HEX >= 0x03050200
// Actually added in 3.5.2, but compiling against that does not guarantee that we get imported there.
@@ -648,7 +652,7 @@ static CYTHON_INLINE void * PyThread_tss
// PyThread_ReInitTLS() is a no-op
#endif /* TSS (Thread Specific Storage) API */
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
+#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000 || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n) PyDict_New()
@@ -662,7 +666,7 @@ static CYTHON_INLINE void * PyThread_tss
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
+#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && PY_VERSION_HEX < 0x030d0000 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
@@ -790,6 +794,16 @@ static CYTHON_INLINE void * PyThread_tss
#define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
#endif
+#if PY_VERSION_HEX >= 0x030d00A1
+ #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name)
+#else
+ static CYTHON_INLINE PyObject *__Pyx_PyImport_AddModuleRef(const char *name) {
+ PyObject *module = PyImport_AddModule(name);
+ Py_XINCREF(module);
+ return module;
+ }
+#endif
+
#if PY_MAJOR_VERSION >= 3
#define PyIntObject PyLongObject
#define PyInt_Type PyLong_Type
@@ -1667,9 +1681,12 @@ static void __Pyx_FastGilFuncInit0(void)
__Pyx_FastGIL_Remember = __Pyx_FastGIL_Remember0;
__Pyx_FastGIL_Forget = __Pyx_FastGIL_Forget0;
capsule = PyCapsule_New(&__Pyx_FastGilFuncs, __Pyx_FastGIL_PyCapsule, NULL);
- abi_module = PyImport_AddModule(__Pyx_FastGIL_ABI_module);
- if (capsule && abi_module) {
- PyObject_SetAttrString(abi_module, __Pyx_FastGIL_PyCapsuleName, capsule);
+ if (capsule) {
+ abi_module = __Pyx_PyImport_AddModuleRef(__Pyx_FastGIL_ABI_module);
+ if (abi_module) {
+ PyObject_SetAttrString(abi_module, __Pyx_FastGIL_PyCapsuleName, capsule);
+ Py_DECREF(abi_module);
+ }
}
Py_XDECREF(capsule);
}
Index: Cython-0.29.37/Cython/Utility/ObjectHandling.c
===================================================================
--- Cython-0.29.37.orig/Cython/Utility/ObjectHandling.c
+++ Cython-0.29.37/Cython/Utility/ObjectHandling.c
@@ -198,7 +198,7 @@ static CYTHON_INLINE PyObject *__Pyx_PyI
next = iternext(iterator);
if (likely(next))
return next;
- #if PY_VERSION_HEX >= 0x02070000 && CYTHON_COMPILING_IN_CPYTHON
+ #if PY_VERSION_HEX >= 0x02070000 && PY_VERSION_HEX < 0x030d0000 && CYTHON_COMPILING_IN_CPYTHON
if (unlikely(iternext == &_PyObject_NextNotImplemented))
return NULL;
#endif
@@ -1151,7 +1151,7 @@ static PyObject *__Pyx__GetNameInClass(P
/////////////// SetNameInClass.proto ///////////////
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
+#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && PY_VERSION_HEX < 0x030d0000
// Identifier names are always interned and have a pre-calculated hash value.
#define __Pyx_SetNameInClass(ns, name, value) \
(likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
@@ -1200,7 +1200,7 @@ static CYTHON_INLINE PyObject *__Pyx__Ge
{
PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
+#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && PY_VERSION_HEX < 0x030d0000
// Identifier names are always interned and have a pre-calculated hash value.
result = _PyDict_GetItem_KnownHash($moddict_cname, name, ((PyASCIIObject *) name)->hash);
__PYX_UPDATE_DICT_CACHE($moddict_cname, result, *dict_cached_value, *dict_version)
@@ -1370,15 +1370,21 @@ static CYTHON_INLINE PyObject* __Pyx_PyO
//@requires: Exceptions.c::PyErrFetchRestore
//@requires: Exceptions.c::PyErrExceptionMatches
+#if __PYX_LIMITED_VERSION_HEX < 0x030d00A1
static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
__Pyx_PyErr_Clear();
}
+#endif
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
PyObject *result;
+#if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1
+ (void) PyObject_GetOptionalAttr(obj, attr_name, &result);
+ return result;
+#else
#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
// _PyObject_GenericGetAttrWithDict() in CPython 3.7+ can avoid raising the AttributeError.
// See https://bugs.python.org/issue32544
@@ -1392,6 +1398,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyO
__Pyx_PyObject_GetAttrStr_ClearAttributeError();
}
return result;
+#endif
}
@@ -1818,14 +1825,24 @@ static PyObject* __Pyx_PyObject_CallMeth
//@requires: PyObjectCallOneArg
//@requires: PyObjectCall2Args
+#if !(CYTHON_VECTORCALL && __PYX_LIMITED_VERSION_HEX >= 0x030C00A2)
static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
// Separate function to avoid excessive inlining.
PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
Py_DECREF(method);
return result;
}
+#endif
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
+#if CYTHON_VECTORCALL && __PYX_LIMITED_VERSION_HEX >= 0x030C00A2
+ PyObject *args[2] = {obj, arg};
+ // avoid unused functions
+ (void) __Pyx_PyObject_GetMethod;
+ (void) __Pyx_PyObject_CallOneArg;
+ (void) __Pyx_PyObject_Call2Args;
+ return PyObject_VectorcallMethod(method_name, args, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
+#else
PyObject *method = NULL, *result;
int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
if (likely(is_method)) {
@@ -1835,6 +1852,7 @@ static PyObject* __Pyx_PyObject_CallMeth
}
if (unlikely(!method)) return NULL;
return __Pyx__PyObject_CallMethod1(method, arg);
+#endif
}
Index: Cython-0.29.37/Cython/Utility/Optimize.c
===================================================================
--- Cython-0.29.37.orig/Cython/Utility/Optimize.c
+++ Cython-0.29.37/Cython/Utility/Optimize.c
@@ -34,7 +34,14 @@ static CYTHON_INLINE int __Pyx_PyList_Ap
Py_ssize_t len = Py_SIZE(list);
if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
Py_INCREF(x);
+ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
+ // In Py3.13a1, PyList_SET_ITEM() checks that the end index is lower than the current size.
+ // However, extending the size *before* setting the value would not be correct,
+ // so we cannot call PyList_SET_ITEM().
+ L->ob_item[len] = x;
+ #else
PyList_SET_ITEM(list, len, x);
+ #endif
__Pyx_SET_SIZE(list, len + 1);
return 0;
}
@@ -52,7 +59,14 @@ static CYTHON_INLINE int __Pyx_ListComp_
Py_ssize_t len = Py_SIZE(list);
if (likely(L->allocated > len)) {
Py_INCREF(x);
+ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
+ // In Py3.13a1, PyList_SET_ITEM() checks that the end index is lower than the current size.
+ // However, extending the size *before* setting the value would not be correct,
+ // so we cannot call PyList_SET_ITEM().
+ L->ob_item[len] = x;
+ #else
PyList_SET_ITEM(list, len, x);
+ #endif
__Pyx_SET_SIZE(list, len + 1);
return 0;
}
@@ -65,7 +79,7 @@ static CYTHON_INLINE int __Pyx_ListComp_
//////////////////// ListExtend.proto ////////////////////
static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
-#if CYTHON_COMPILING_IN_CPYTHON
+#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000
PyObject* none = _PyList_Extend((PyListObject*)L, v);
if (unlikely(!none))
return -1;
@@ -279,7 +293,7 @@ static CYTHON_INLINE PyObject *__Pyx_PyD
/////////////// py_dict_pop ///////////////
static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value) {
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B3
+#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B3 & PY_VERSION_HEX < 0x030d0000
if ((1)) {
return _PyDict_Pop(d, key, default_value);
} else
@@ -435,7 +449,7 @@ static CYTHON_INLINE int __Pyx_set_iter_
static CYTHON_INLINE PyObject* __Pyx_set_iterator(PyObject* iterable, int is_set,
Py_ssize_t* p_orig_length, int* p_source_is_set) {
-#if CYTHON_COMPILING_IN_CPYTHON
+#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000
is_set = is_set || likely(PySet_CheckExact(iterable) || PyFrozenSet_CheckExact(iterable));
*p_source_is_set = is_set;
if (likely(is_set)) {
@@ -455,7 +469,7 @@ static CYTHON_INLINE int __Pyx_set_iter_
PyObject* iter_obj, Py_ssize_t orig_length,
Py_ssize_t* ppos, PyObject **value,
int source_is_set) {
- if (!CYTHON_COMPILING_IN_CPYTHON || unlikely(!source_is_set)) {
+ if (!CYTHON_COMPILING_IN_CPYTHON || PY_VERSION_HEX >= 0x030d0000 || unlikely(!source_is_set)) {
*value = PyIter_Next(iter_obj);
if (unlikely(!*value)) {
return __Pyx_IterFinish();
@@ -464,7 +478,7 @@ static CYTHON_INLINE int __Pyx_set_iter_
(void)ppos;
return 1;
}
-#if CYTHON_COMPILING_IN_CPYTHON
+#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000
if (unlikely(PySet_GET_SIZE(iter_obj) != orig_length)) {
PyErr_SetString(
PyExc_RuntimeError,
Index: Cython-0.29.37/Cython/Utility/StringTools.c
===================================================================
--- Cython-0.29.37.orig/Cython/Utility/StringTools.c
+++ Cython-0.29.37/Cython/Utility/StringTools.c
@@ -804,25 +804,22 @@ static CYTHON_INLINE char __Pyx_PyBytes_
#define __Pyx_PyString_Join PyUnicode_Join
#define __Pyx_PyBaseString_Join PyUnicode_Join
#endif
-
-#if CYTHON_COMPILING_IN_CPYTHON
- #if PY_MAJOR_VERSION < 3
- #define __Pyx_PyBytes_Join _PyString_Join
- #else
- #define __Pyx_PyBytes_Join _PyBytes_Join
- #endif
-#else
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values); /*proto*/
-#endif
-
//////////////////// StringJoin ////////////////////
+//@requires: ObjectHandling.c::PyObjectCallMethod1
-#if !CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
- return PyObject_CallMethodObjArgs(sep, PYIDENT("join"), values, NULL);
-}
+ // avoid unused function
+ (void) __Pyx_PyObject_CallMethod1;
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION < 3
+ return _PyString_Join(sep, values);
+#elif CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000
+ return _PyBytes_Join(sep, values);
+#else
+ return __Pyx_PyObject_CallMethod1(sep, PYIDENT("join"), values);
#endif
+}
/////////////// JoinPyUnicode.proto ///////////////
@@ -873,8 +870,8 @@ static PyObject* __Pyx_PyUnicode_Join(Py
if (!CYTHON_PEP393_ENABLED || ukind == result_ukind) {
memcpy((char *)result_udata + char_pos * result_ukind, udata, (size_t) (ulength * result_ukind));
} else {
- #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0 || defined(_PyUnicode_FastCopyCharacters)
- _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
+ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0 || defined(_PyUnicode_CopyCharacters)
+ PyUnicode_CopyCharacters(result_uval, char_pos, uval, 0, ulength);
#else
Py_ssize_t j;
for (j=0; j < ulength; j++) {
Index: Cython-0.29.37/Cython/Utility/TypeConversion.c
===================================================================
--- Cython-0.29.37.orig/Cython/Utility/TypeConversion.c
+++ Cython-0.29.37/Cython/Utility/TypeConversion.c
@@ -679,8 +679,23 @@ static CYTHON_INLINE PyObject* {{TO_PY_F
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
+#if PY_VERSION_HEX < 0x030d0000
return _PyLong_FromByteArray(bytes, sizeof({{TYPE}}),
little, !is_unsigned);
+#else
+ PyObject *from_bytes, *result = NULL, *kwds = NULL;
+ PyObject *py_bytes = NULL, *arg_tuple = NULL, *order_str = NULL;
+ from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
+ if (!from_bytes) return NULL;
+ py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof({{TYPE}}));
+ order_str = PyUnicode_FromString(little ? "little" : "big");
+ arg_tuple = PyTuple_Pack(2, py_bytes, order_str);
+ if (!is_unsigned) {
+ // default is signed=False
+ kwds = PyDict_New();
+ }
+ result = PyObject_Call(from_bytes, arg_tuple, kwds);
+#endif
}
}
@@ -984,6 +999,7 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_
}
#endif
if (likely(v)) {
+#if PY_VERSION_HEX < 0x030d0000
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
@@ -992,6 +1008,7 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_
Py_DECREF(v);
if (likely(!ret))
return val;
+#endif
}
#endif
return ({{TYPE}}) -1;
Index: Cython-0.29.37/tests/run/set_iter.pyx
===================================================================
--- Cython-0.29.37.orig/tests/run/set_iter.pyx
+++ Cython-0.29.37/tests/run/set_iter.pyx
@@ -65,9 +65,9 @@ def set_iter_modify(set s, int value):
[1, 2, 3]
>>> sorted(set_iter_modify(s, 3))
[1, 2, 3]
- >>> sorted(set_iter_modify(s, 4))
+ >>> sorted(set_iter_modify(s, 4)) # doctest: +ELLIPSIS
Traceback (most recent call last):
- RuntimeError: set changed size during iteration
+ RuntimeError: ...et changed size during iteration
"""
for x in s:
s.add(value)

4
python-Cython0-rpmlintrc Normal file
View File

@@ -0,0 +1,4 @@
addFilter('devel-file-in-non-devel-package .*/Cython/.*')
addFilter('devel-dependency python39-devel')
addFilter('devel-dependency python310-devel')
addFilter('devel-dependency python311-devel')

1833
python-Cython0.changes Normal file

File diff suppressed because it is too large Load Diff

104
python-Cython0.spec Normal file
View File

@@ -0,0 +1,104 @@
#
# spec file for package python-Cython0
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?sle15_python_module_pythons}
%bcond_with test
Name: python-Cython0
Version: 0.29.37
Release: 0
Summary: The Cython compiler for writing C extensions for the Python language
License: Apache-2.0
URL: https://cython.org/
Source: https://files.pythonhosted.org/packages/source/C/Cython/Cython-%{version}.tar.gz
Source1: python-Cython0-rpmlintrc
# PATCH-FIX-UPSTREAM backported https://github.com/cython/cython/pull/5767 Adapt to C-API changes in CPython 3.13
Patch0: py313.patch
BuildRequires: %{python_module devel}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: %{python_module xml}
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: python-rpm-macros
Provides: python-Cython = %{version}-%{release}
Provides: python-cython = %{version}-%{release}
Requires: python-devel
Requires: python-xml
Requires(post): update-alternatives
Requires(postun): update-alternatives
%python_subpackages
%description
The Cython language allows for writing C extensions for the Python
language. Cython is a source code translator based on Pyrex, but
supports more cutting edge functionality and optimizations.
The Cython language is very close to the Python language (and most Python
code is also valid Cython code), but Cython additionally supports calling C
functions and declaring C types on variables and class attributes. This
allows the compiler to generate very efficient C code from Cython code.
%prep
%autosetup -p1 -n Cython-%{version}
# Fix non-executable scripts
sed -i "s|^#!.*||" Cython/Debugger/{libpython,Cygdb}.py cython.py
%build
export CFLAGS="%{optflags} -fno-strict-aliasing"
%pyproject_wheel
%install
%pyproject_install
for p in cython cythonize cygdb ; do
%python_clone -a %{buildroot}%{_bindir}/$p
done
%{python_expand chmod a+x %{buildroot}%{$python_sitearch}/Cython/Build/Cythonize.py
sed -i "s|^#!%{_bindir}/env python$|#!%{__$python}|" %{buildroot}%{$python_sitearch}/Cython/Build/Cythonize.py
$python -m compileall -d %{$python_sitearch} %{buildroot}%{$python_sitearch}/Cython/Build/
$python -O -m compileall -d %{$python_sitearch} %{buildroot}%{$python_sitearch}/Cython/Build/
%fdupes %{buildroot}%{$python_sitearch}
}
%check
%if %{with test}
%{python_expand export PYTHONPATH=%{buildroot}%{$python_sitearch} PYTHONDONTWRITEBYTECODE=1
$python runtests.py -v
}
%endif
%post
%python_install_alternative cython cythonize cygdb
%postun
%python_uninstall_alternative cython
%files %{python_files}
%license LICENSE.txt COPYING.txt
%doc README.rst ToDo.txt USAGE.txt
%python_alternative %{_bindir}/cygdb
%python_alternative %{_bindir}/cython
%python_alternative %{_bindir}/cythonize
%{python_sitearch}/Cython/
%{python_sitearch}/Cython-%{version}*-info
%{python_sitearch}/cython.py*
%pycache_only %{python_sitearch}/__pycache__/cython*.py*
%{python_sitearch}/pyximport/
%changelog