Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
home:rhabacker:branches:Application:Geo
python-Cython0
py313.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File py313.patch of Package python-Cython0
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)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor