Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-Cython for openSUSE:Factory checked in at 2022-05-20 17:50:15 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-Cython (Old) and /work/SRC/openSUSE:Factory/.python-Cython.new.1538 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-Cython" Fri May 20 17:50:15 2022 rev:65 rq:977998 version:0.29.30 Changes: -------- --- /work/SRC/openSUSE:Factory/python-Cython/python-Cython.changes 2022-03-23 20:15:21.998361165 +0100 +++ /work/SRC/openSUSE:Factory/.python-Cython.new.1538/python-Cython.changes 2022-05-20 17:50:20.847205573 +0200 @@ -1,0 +2,14 @@ +Wed May 18 08:35:39 UTC 2022 - Paolo Stivanin <i...@paolostivanin.com> + +- update to 0.29.30: + * Avoid acquiring the GIL at the end of nogil functions. This change + was backported in order to avoid generating wrong C code that + would trigger C compiler warnings with tracing support enabled. + * Function definitions in finally: clauses were not correctly generated. + * A case where C-API functions could be called with a live exception + set was fixed. + * Cython now correctly generates Python methods for both the provided + regular and reversed special numeric methods of extension types. + * The C union type in pure Python mode mishandled some field names. + +------------------------------------------------------------------- Old: ---- Cython-0.29.28.tar.gz New: ---- Cython-0.29.30.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-Cython.spec ++++++ --- /var/tmp/diff_new_pack.HqY17A/_old 2022-05-20 17:50:23.303207770 +0200 +++ /var/tmp/diff_new_pack.HqY17A/_new 2022-05-20 17:50:23.307207774 +0200 @@ -20,7 +20,7 @@ %define oldpython python %bcond_with test Name: python-Cython -Version: 0.29.28 +Version: 0.29.30 Release: 0 Summary: The Cython compiler for writing C extensions for the Python language License: Apache-2.0 ++++++ Cython-0.29.28.tar.gz -> Cython-0.29.30.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/.gitrev new/Cython-0.29.30/.gitrev --- old/Cython-0.29.28/.gitrev 2022-02-17 00:58:34.915900500 +0100 +++ new/Cython-0.29.30/.gitrev 2022-05-17 18:38:40.361280000 +0200 @@ -1 +1 @@ -27b6709241461f620fb25756ef9f1192cc4f589a +a6f04ef2430fb4e7383a068cd1ae9a115d7a78df diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/CHANGES.rst new/Cython-0.29.30/CHANGES.rst --- old/Cython-0.29.28/CHANGES.rst 2022-02-17 00:58:31.495433000 +0100 +++ new/Cython-0.29.30/CHANGES.rst 2022-05-17 18:38:34.117270200 +0200 @@ -2,6 +2,65 @@ Cython Changelog ================ +0.29.30 (2022-05-16) +==================== + +Bugs fixed +---------- + +* The GIL handling changes in 0.29.29 introduced a regression where + objects could be deallocated without holding the GIL. + (Github issue #4796) + + +0.29.29 (2022-05-16) +==================== + +Features added +-------------- + +* Avoid acquiring the GIL at the end of nogil functions. + This change was backported in order to avoid generating wrong C code + that would trigger C compiler warnings with tracing support enabled. + Backport by Oleksandr Pavlyk. (Github issue #4637) + +Bugs fixed +---------- + +* Function definitions in ``finally:`` clauses were not correctly generated. + Patch by David Woods. (Github issue #4651) + +* A case where C-API functions could be called with a live exception set was fixed. + Patch by Jakub Kul??k. (Github issue #4722) + +* Pickles can now be exchanged again with those generated from Cython 3.0 modules. + (Github issue #4680) + +* Cython now correctly generates Python methods for both the provided regular and + reversed special numeric methods of extension types. + Patch by David Woods. (Github issue #4750) + +* Calling unbound extension type methods without arguments could raise an + ``IndexError`` instead of a ``TypeError``. + Patch by David Woods. (Github issue #4779) + +* Calling unbound ``.__contains__()`` super class methods on some builtin base + types could trigger an infinite recursion. + Patch by David Woods. (Github issue #4785) + +* The C union type in pure Python mode mishandled some field names. + Patch by Jordan Bri??re. (Github issue #4727) + +* Allow users to overwrite the C macro ``_USE_MATH_DEFINES``. + Patch by Yuriy Chernyshov. (Github issue #4690) + +* Improved compatibility with CPython 3.10/11. + Patches by Thomas Caswell, David Woods. (Github issues #4609, #4667, #4721, #4730, #4777) + +* Docstrings of descriptors are now provided in PyPy 7.3.9. + Patch by Matti Picus. (Github issue #4701) + + 0.29.28 (2022-02-17) ==================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/Cython/Compiler/Builtin.py new/Cython-0.29.30/Cython/Compiler/Builtin.py --- old/Cython-0.29.28/Cython/Compiler/Builtin.py 2022-02-17 00:58:31.495433000 +0100 +++ new/Cython-0.29.30/Cython/Compiler/Builtin.py 2022-05-17 18:38:34.121270200 +0200 @@ -271,12 +271,10 @@ ]), ("bytearray", "PyByteArray_Type", [ ]), - ("bytes", "PyBytes_Type", [BuiltinMethod("__contains__", "TO", "b", "PySequence_Contains"), - BuiltinMethod("join", "TO", "O", "__Pyx_PyBytes_Join", + ("bytes", "PyBytes_Type", [BuiltinMethod("join", "TO", "O", "__Pyx_PyBytes_Join", utility_code=UtilityCode.load("StringJoin", "StringTools.c")), ]), - ("str", "PyString_Type", [BuiltinMethod("__contains__", "TO", "b", "PySequence_Contains"), - BuiltinMethod("join", "TO", "O", "__Pyx_PyString_Join", + ("str", "PyString_Type", [BuiltinMethod("join", "TO", "O", "__Pyx_PyString_Join", builtin_return_type='basestring', utility_code=UtilityCode.load("StringJoin", "StringTools.c")), ]), @@ -284,11 +282,9 @@ BuiltinMethod("join", "TO", "T", "PyUnicode_Join"), ]), - ("tuple", "PyTuple_Type", [BuiltinMethod("__contains__", "TO", "b", "PySequence_Contains"), - ]), + ("tuple", "PyTuple_Type", []), - ("list", "PyList_Type", [BuiltinMethod("__contains__", "TO", "b", "PySequence_Contains"), - BuiltinMethod("insert", "TzO", "r", "PyList_Insert"), + ("list", "PyList_Type", [BuiltinMethod("insert", "TzO", "r", "PyList_Insert"), BuiltinMethod("reverse", "T", "r", "PyList_Reverse"), BuiltinMethod("append", "TO", "r", "__Pyx_PyList_Append", utility_code=UtilityCode.load("ListAppend", "Optimize.c")), @@ -326,8 +322,7 @@ ]), # ("file", "PyFile_Type", []), # not in Py3 - ("set", "PySet_Type", [BuiltinMethod("__contains__", "TO", "b", "PySequence_Contains"), - BuiltinMethod("clear", "T", "r", "PySet_Clear"), + ("set", "PySet_Type", [BuiltinMethod("clear", "T", "r", "PySet_Clear"), # discard() and remove() have a special treatment for unhashable values BuiltinMethod("discard", "TO", "r", "__Pyx_PySet_Discard", utility_code=UtilityCode.load("py_set_discard", "Optimize.c")), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/Cython/Compiler/Code.py new/Cython-0.29.30/Cython/Compiler/Code.py --- old/Cython-0.29.28/Cython/Compiler/Code.py 2022-02-17 00:58:31.495433000 +0100 +++ new/Cython-0.29.30/Cython/Compiler/Code.py 2022-05-17 18:38:34.121270200 +0200 @@ -2233,8 +2233,8 @@ method_flags = entry.signature.method_flags() if not method_flags: return - if entry.is_special: - from . import TypeSlots + from . import TypeSlots + if entry.is_special or TypeSlots.is_reverse_number_slot(entry.name): method_flags += [TypeSlots.method_coexist] func_ptr = wrapper_code_writer.put_pymethoddef_wrapper(entry) if wrapper_code_writer else entry.func_cname # Add required casts, but try not to shadow real warnings. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/Cython/Compiler/Nodes.py new/Cython-0.29.30/Cython/Compiler/Nodes.py --- old/Cython-0.29.28/Cython/Compiler/Nodes.py 2022-02-17 00:58:31.503433200 +0100 +++ new/Cython-0.29.30/Cython/Compiler/Nodes.py 2022-05-17 18:38:34.125270100 +0200 @@ -3461,7 +3461,7 @@ docstr.as_c_string_literal())) if entry.is_special: - code.putln('#if CYTHON_COMPILING_IN_CPYTHON') + code.putln('#if CYTHON_UPDATE_DESCRIPTOR_DOC') code.putln( "struct wrapperbase %s;" % entry.wrapperbase_cname) code.putln('#endif') @@ -4956,7 +4956,7 @@ preprocessor_guard = slot.preprocessor_guard_code() if slot else None if preprocessor_guard: code.putln(preprocessor_guard) - code.putln('#if CYTHON_COMPILING_IN_CPYTHON') + code.putln('#if CYTHON_UPDATE_DESCRIPTOR_DOC') code.putln("{") code.putln( 'PyObject *wrapper = PyObject_GetAttrString((PyObject *)&%s, "%s"); %s' % ( @@ -7702,6 +7702,8 @@ def generate_function_definitions(self, env, code): self.body.generate_function_definitions(env, code) self.finally_clause.generate_function_definitions(env, code) + if self.finally_except_clause: + self.finally_except_clause.generate_function_definitions(env, code) def put_error_catcher(self, code, temps_to_clean_up, exc_vars, exc_lineno_cnames=None, exc_filename_cname=None): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/Cython/Compiler/ParseTreeTransforms.py new/Cython-0.29.30/Cython/Compiler/ParseTreeTransforms.py --- old/Cython-0.29.28/Cython/Compiler/ParseTreeTransforms.py 2022-02-17 00:58:31.503433200 +0100 +++ new/Cython-0.29.30/Cython/Compiler/ParseTreeTransforms.py 2022-05-17 18:38:34.129270300 +0200 @@ -1701,7 +1701,23 @@ e.type.create_to_py_utility_code(env) e.type.create_from_py_utility_code(env) all_members_names = sorted([e.name for e in all_members]) - checksum = '0x%s' % hashlib.md5(' '.join(all_members_names).encode('utf-8')).hexdigest()[:7] + + # Cython 0.x used MD5 for the checksum, which a few Python installations remove for security reasons. + # SHA-256 should be ok for years to come, but early Cython 3.0 alpha releases used SHA-1, + # which may not be. + checksum_algos = [] + try: + checksum_algos.append(hashlib.md5) + except AttributeError: + pass + checksum_algos.append(hashlib.sha256) + checksum_algos.append(hashlib.sha1) + + member_names_string = ' '.join(all_members_names).encode('utf-8') + checksums = [ + '0x' + mkchecksum(member_names_string).hexdigest()[:7] + for mkchecksum in checksum_algos + ] unpickle_func_name = '__pyx_unpickle_%s' % node.class_name # TODO(robertwb): Move the state into the third argument @@ -1710,9 +1726,9 @@ def %(unpickle_func_name)s(__pyx_type, long __pyx_checksum, __pyx_state): cdef object __pyx_PickleError cdef object __pyx_result - if __pyx_checksum != %(checksum)s: + if __pyx_checksum not in %(checksums)s: from pickle import PickleError as __pyx_PickleError - raise __pyx_PickleError("Incompatible checksums (%%s vs %(checksum)s = (%(members)s))" %% __pyx_checksum) + raise __pyx_PickleError("Incompatible checksums (0x%%x vs %(checksums)s = (%(members)s))" %% __pyx_checksum) __pyx_result = %(class_name)s.__new__(__pyx_type) if __pyx_state is not None: %(unpickle_func_name)s__set_state(<%(class_name)s> __pyx_result, __pyx_state) @@ -1724,7 +1740,7 @@ __pyx_result.__dict__.update(__pyx_state[%(num_members)d]) """ % { 'unpickle_func_name': unpickle_func_name, - 'checksum': checksum, + 'checksums': "(%s)" % ', '.join(checksums), 'members': ', '.join(all_members_names), 'class_name': node.class_name, 'assignments': '; '.join( @@ -1757,7 +1773,7 @@ %(unpickle_func_name)s__set_state(self, __pyx_state) """ % { 'unpickle_func_name': unpickle_func_name, - 'checksum': checksum, + 'checksum': checksums[0], 'members': ', '.join('self.%s' % v for v in all_members_names) + (',' if len(all_members_names) == 1 else ''), # Even better, we could check PyType_IS_GC. 'any_notnone_members' : ' or '.join(['self.%s is not None' % e.name for e in all_members if e.type.is_pyobject] or ['False']), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/Cython/Compiler/TypeSlots.py new/Cython-0.29.30/Cython/Compiler/TypeSlots.py --- old/Cython-0.29.28/Cython/Compiler/TypeSlots.py 2022-02-17 00:58:31.507433200 +0100 +++ new/Cython-0.29.30/Cython/Compiler/TypeSlots.py 2022-05-17 18:38:34.133270300 +0200 @@ -625,6 +625,20 @@ slot = get_slot_by_name(slot_name) return slot.slot_code(scope) +def is_reverse_number_slot(name): + """ + Tries to identify __radd__ and friends (so the METH_COEXIST flag can be applied). + + There's no great consequence if it inadvertently identifies a few other methods + so just use a simple rule rather than an exact list. + """ + if name.startswith("__r") and name.endswith("__"): + forward_name = name.replace("r", "", 1) + for meth in PyNumberMethods: + if getattr(meth, "method_name", None) == forward_name: + return True + return False + #------------------------------------------------------------------------------------------ # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/Cython/Shadow.py new/Cython-0.29.30/Cython/Shadow.py --- old/Cython-0.29.28/Cython/Shadow.py 2022-02-17 00:58:31.515433300 +0100 +++ new/Cython-0.29.30/Cython/Shadow.py 2022-05-17 18:38:34.145270300 +0200 @@ -1,7 +1,7 @@ # cython.* namespace for pure mode. from __future__ import absolute_import -__version__ = "0.29.28" +__version__ = "0.29.30" try: from __builtin__ import basestring @@ -305,7 +305,7 @@ setattr(self, key, value) def __setattr__(self, key, value): - if key in '__dict__': + if key == '__dict__': CythonType.__setattr__(self, key, value) elif key in self._members: self.__dict__ = {key: cast(self._members[key], value)} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/Cython/Utility/Coroutine.c new/Cython-0.29.30/Cython/Utility/Coroutine.c --- old/Cython-0.29.28/Cython/Utility/Coroutine.c 2022-02-17 00:58:31.519433300 +0100 +++ new/Cython-0.29.30/Cython/Utility/Coroutine.c 2022-05-17 18:38:34.149270300 +0200 @@ -490,6 +490,12 @@ #include <structmember.h> #include <frameobject.h> +#if PY_VERSION_HEX >= 0x030b00a6 + #ifndef Py_BUILD_CORE + #define Py_BUILD_CORE 1 + #endif + #include "internal/pycore_frame.h" +#endif #define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/Cython/Utility/CythonFunction.c new/Cython-0.29.30/Cython/Utility/CythonFunction.c --- old/Cython-0.29.28/Cython/Utility/CythonFunction.c 2022-02-17 00:58:31.519433300 +0100 +++ new/Cython-0.29.30/Cython/Utility/CythonFunction.c 2022-05-17 18:38:34.149270300 +0200 @@ -660,6 +660,9 @@ self = PyTuple_GetItem(args, 0); if (unlikely(!self)) { Py_DECREF(new_args); + PyErr_Format(PyExc_TypeError, + "unbound method %.200S() needs an argument", + cyfunc->func_qualname); return NULL; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/Cython/Utility/Exceptions.c new/Cython-0.29.30/Cython/Utility/Exceptions.c --- old/Cython-0.29.28/Cython/Utility/Exceptions.c 2022-02-17 00:58:31.519433300 +0100 +++ new/Cython-0.29.30/Cython/Utility/Exceptions.c 2022-05-17 18:38:34.149270300 +0200 @@ -705,6 +705,12 @@ #include "compile.h" #include "frameobject.h" #include "traceback.h" +#if PY_VERSION_HEX >= 0x030b00a6 + #ifndef Py_BUILD_CORE + #define Py_BUILD_CORE 1 + #endif + #include "internal/pycore_frame.h" +#endif static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, @@ -772,6 +778,7 @@ PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject *ptype, *pvalue, *ptraceback; if (c_line) { c_line = __Pyx_CLineForTraceback(tstate, c_line); @@ -780,9 +787,18 @@ // Negate to avoid collisions between py and c lines. py_code = $global_code_object_cache_find(c_line ? -c_line : py_line); if (!py_code) { + __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); - if (!py_code) goto bad; + if (!py_code) { + /* If the code object creation fails, then we should clear the + fetched exception references and propagate the new exception */ + Py_XDECREF(ptype); + Py_XDECREF(pvalue); + Py_XDECREF(ptraceback); + goto bad; + } + __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); $global_code_object_cache_insert(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/Cython/Utility/ExtensionTypes.c new/Cython-0.29.30/Cython/Utility/ExtensionTypes.c --- old/Cython-0.29.28/Cython/Utility/ExtensionTypes.c 2022-02-17 00:58:31.519433300 +0100 +++ new/Cython-0.29.30/Cython/Utility/ExtensionTypes.c 2022-05-17 18:38:34.149270300 +0200 @@ -204,18 +204,37 @@ static int __Pyx_setup_reduce(PyObject* type_obj) { int ret = 0; PyObject *object_reduce = NULL; + PyObject *object_getstate = NULL; PyObject *object_reduce_ex = NULL; PyObject *reduce = NULL; PyObject *reduce_ex = NULL; PyObject *reduce_cython = NULL; PyObject *setstate = NULL; PyObject *setstate_cython = NULL; + PyObject *getstate = NULL; #if CYTHON_USE_PYTYPE_LOOKUP - if (_PyType_Lookup((PyTypeObject*)type_obj, PYIDENT("__getstate__"))) goto __PYX_GOOD; + getstate = _PyType_Lookup((PyTypeObject*)type_obj, PYIDENT("__getstate__")); #else - if (PyObject_HasAttr(type_obj, PYIDENT("__getstate__"))) goto __PYX_GOOD; + getstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, PYIDENT("__getstate__")); + if (!getstate && PyErr_Occurred()) { + goto __PYX_BAD; + } #endif + if (getstate) { + // Python 3.11 introduces object.__getstate__. Because it's version-specific failure to find it should not be an error +#if CYTHON_USE_PYTYPE_LOOKUP + object_getstate = _PyType_Lookup(&PyBaseObject_Type, PYIDENT("__getstate__")); +#else + object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, PYIDENT("__getstate__")); + if (!object_getstate && PyErr_Occurred()) { + goto __PYX_BAD; + } +#endif + if (object_getstate != getstate) { + goto __PYX_GOOD; + } + } #if CYTHON_USE_PYTYPE_LOOKUP object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, PYIDENT("__reduce_ex__")); if (!object_reduce_ex) goto __PYX_BAD; @@ -270,6 +289,8 @@ #if !CYTHON_USE_PYTYPE_LOOKUP Py_XDECREF(object_reduce); Py_XDECREF(object_reduce_ex); + Py_XDECREF(object_getstate); + Py_XDECREF(getstate); #endif Py_XDECREF(reduce); Py_XDECREF(reduce_ex); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/Cython/Utility/ModuleSetupCode.c new/Cython-0.29.30/Cython/Utility/ModuleSetupCode.c --- old/Cython-0.29.28/Cython/Utility/ModuleSetupCode.c 2022-02-17 00:58:31.519433300 +0100 +++ new/Cython-0.29.30/Cython/Utility/ModuleSetupCode.c 2022-05-17 18:38:34.149270300 +0200 @@ -83,6 +83,9 @@ #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_HEX >= 0x07030900) + #endif #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 @@ -126,6 +129,9 @@ #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 + #endif #else #define CYTHON_COMPILING_IN_PYPY 0 @@ -186,7 +192,8 @@ #ifndef CYTHON_FAST_PYCALL // Python 3.11 deleted localplus argument from frame object, which is used in our // fast_pycall code - #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030B00A1) + // On Python 3.10 it causes issues when used while profiling/debugging + #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030A0000) #endif #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) @@ -203,6 +210,9 @@ #elif !defined(CYTHON_USE_EXC_INFO_STACK) #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) #endif + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 + #endif #endif #if !defined(CYTHON_FAST_PYCCALL) @@ -963,8 +973,10 @@ /////////////// MathInitCode /////////////// -#if defined(WIN32) || defined(MS_WINDOWS) - #define _USE_MATH_DEFINES +#if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS) + #if !defined(_USE_MATH_DEFINES) + #define _USE_MATH_DEFINES + #endif #endif #include <math.h> @@ -1211,11 +1223,37 @@ /////////////// CheckBinaryVersion /////////////// static int __Pyx_check_binary_version(void) { - char ctversion[4], rtversion[4]; - PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); - PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); - if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char ctversion[5]; + int same=1, i, found_dot; + const char* rt_from_call = Py_GetVersion(); + PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + // slightly convoluted, but now that we're into double digit version numbers we can no longer just rely on the length. + found_dot = 0; + for (i = 0; i < 4; i++) { + if (!ctversion[i]) { + // if they are the same, just check that the runtime version doesn't continue with further numbers + same = (rt_from_call[i] < '0' || rt_from_call[i] > '9'); + break; + } + if (rt_from_call[i] != ctversion[i]) { + same = 0; + break; + } + } + + if (!same) { + char rtversion[5] = {'\0'}; + // copy the runtime-version for the error message char message[200]; + for (i=0; i<4; ++i) { + if (rt_from_call[i] == '.') { + if (found_dot) break; + found_dot = 1; + } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') { + break; + } + rtversion[i] = rt_from_call[i]; + } PyOS_snprintf(message, sizeof(message), "compiletime version %s of module '%.100s' " "does not match runtime version %s", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/Cython/Utility/ObjectHandling.c new/Cython-0.29.30/Cython/Utility/ObjectHandling.c --- old/Cython-0.29.28/Cython/Utility/ObjectHandling.c 2022-02-17 00:58:31.519433300 +0100 +++ new/Cython-0.29.30/Cython/Utility/ObjectHandling.c 2022-05-17 18:38:34.149270300 +0200 @@ -1996,6 +1996,13 @@ static size_t __pyx_pyframe_localsplus_offset = 0; #include "frameobject.h" +#if PY_VERSION_HEX >= 0x030b00a6 + #ifndef Py_BUILD_CORE + #define Py_BUILD_CORE 1 + #endif + #include "internal/pycore_frame.h" +#endif + // This is the long runtime version of // #define __Pyx_PyFrame_GetLocalsplus(frame) ((frame)->f_localsplus) // offsetof(PyFrameObject, f_localsplus) differs between regular C-Python and Stackless Python. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/Cython/Utility/Profile.c new/Cython-0.29.30/Cython/Utility/Profile.c --- old/Cython-0.29.28/Cython/Utility/Profile.c 2022-02-17 00:58:31.519433300 +0100 +++ new/Cython-0.29.30/Cython/Utility/Profile.c 2022-05-17 18:38:34.149270300 +0200 @@ -38,6 +38,12 @@ #include "compile.h" #include "frameobject.h" #include "traceback.h" +#if PY_VERSION_HEX >= 0x030b00a6 + #ifndef Py_BUILD_CORE + #define Py_BUILD_CORE 1 + #endif + #include "internal/pycore_frame.h" +#endif #if CYTHON_PROFILE_REUSE_FRAME #define CYTHON_FRAME_MODIFIER static diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/Cython/Utility/StringTools.c new/Cython-0.29.30/Cython/Utility/StringTools.c --- old/Cython-0.29.28/Cython/Utility/StringTools.c 2022-02-17 00:58:31.519433300 +0100 +++ new/Cython-0.29.30/Cython/Utility/StringTools.c 2022-05-17 18:38:34.149270300 +0200 @@ -314,7 +314,7 @@ return (equals == Py_EQ); } else { int result; -#if CYTHON_USE_UNICODE_INTERNALS +#if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000) Py_hash_t hash1, hash2; hash1 = ((PyBytesObject*)s1)->ob_shash; hash2 = ((PyBytesObject*)s2)->ob_shash; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/PKG-INFO new/Cython-0.29.30/PKG-INFO --- old/Cython-0.29.28/PKG-INFO 2022-02-17 00:58:40.736295700 +0100 +++ new/Cython-0.29.30/PKG-INFO 2022-05-17 18:38:47.409286300 +0200 @@ -1,12 +1,11 @@ Metadata-Version: 2.1 Name: Cython -Version: 0.29.28 +Version: 0.29.30 Summary: The Cython compiler for writing C extensions for the Python language. Home-page: http://cython.org/ Author: Robert Bradshaw, Stefan Behnel, Dag Seljebotn, Greg Ewing, et al. Author-email: cython-de...@python.org License: Apache -Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Apache Software License @@ -56,5 +55,3 @@ pip install Cython --install-option="--no-cython-compile" .. _Pyrex: http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ - - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/docs/src/userguide/extension_types.rst new/Cython-0.29.30/docs/src/userguide/extension_types.rst --- old/Cython-0.29.28/docs/src/userguide/extension_types.rst 2022-02-17 00:58:31.535433500 +0100 +++ new/Cython-0.29.30/docs/src/userguide/extension_types.rst 2022-05-17 18:38:34.169270300 +0200 @@ -675,7 +675,7 @@ One can also annotate with ``@cython.auto_pickle(False)`` to get the old behavior of not generating a ``__reduce__`` method in any case. -Manually implementing a ``__reduce__`` or `__reduce_ex__`` method will also +Manually implementing a ``__reduce__`` or ``__reduce_ex__`` method will also disable this auto-generation and can be used to support pickling of more complicated types. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/tests/build/depfile_package.srctree new/Cython-0.29.30/tests/build/depfile_package.srctree --- old/Cython-0.29.28/tests/build/depfile_package.srctree 2022-02-17 00:58:31.543433400 +0100 +++ new/Cython-0.29.30/tests/build/depfile_package.srctree 2022-05-17 18:38:34.173270200 +0200 @@ -7,13 +7,13 @@ import os.path -with open("pkg/test.c.dep", "r") as f: +with open(os.path.join("pkg", "test.c.dep"), "r") as f: contents = f.read().replace("\\\n", " ").replace("\n", " ") assert sorted(contents.split()) == sorted(['test.c:', os.path.join('sub', 'incl.pxi'), 'test.pxd', 'test.pyx']), contents -with open("pkg/sub/test.c.dep", "r") as f: +with open(os.path.join("pkg", "sub", "test.c.dep"), "r") as f: contents = f.read().replace("\\\n", " ").replace("\n", " ") contents = [os.path.relpath(entry, '.') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/tests/run/builtin_subtype_methods_T653.pyx new/Cython-0.29.30/tests/run/builtin_subtype_methods_T653.pyx --- old/Cython-0.29.28/tests/run/builtin_subtype_methods_T653.pyx 2022-02-17 00:58:31.555433500 +0100 +++ new/Cython-0.29.30/tests/run/builtin_subtype_methods_T653.pyx 2022-05-17 18:38:34.193270400 +0200 @@ -4,7 +4,21 @@ cimport cython +# The "contains" tests relate to GH-4785 - replacing the method +# call with PySequence_Contains was causing infinite recursion +# for some classes + cdef class MyList(list): + """ + >>> l = MyList() + >>> l.__contains__(1) + MyList.__contains__ + False + >>> l.append(1) + >>> l.__contains__(1) + MyList.__contains__ + True + """ def test_append(self, x): """ >>> l = MyList() @@ -18,7 +32,13 @@ """ self.append(x) + def __contains__(self, value): + print "MyList.__contains__" + return list.__contains__(self, value) # probably optimized + cdef class MyDict(dict): + # tests for __contains__ are in the global __doc__ to version-check a PyPy bug + @cython.test_assert_path_exists("//ComprehensionNode//AttributeNode", "//ComprehensionNode//AttributeNode[@attribute='items']") @cython.test_fail_if_path_exists("//ComprehensionNode//CMethodSelfCloneNode") @@ -40,6 +60,19 @@ l.sort() return l + def __contains__(self, key): + print "MyDict.__contains__" + return dict.__contains__(self, key) + +import sys +pypy_version = getattr(sys, 'pypy_version_info', None) +if not (pypy_version and pypy_version < (7, 3, 10)): + __doc__ = """ + >>> MyDict(a=1).__contains__("a") + MyDict.__contains__ + True + """ + @cython.final cdef class MyDictFinal(dict): @cython.test_assert_path_exists("//ComprehensionNode//CMethodSelfCloneNode") @@ -155,3 +188,17 @@ l = [ v for v in self.values() ] l.sort() return l + +class MyBytes(bytes): + """ + >>> mb = MyBytes(b"abc") + >>> mb.__contains__(b"a") + MyBytes.__contains__ + True + >>> mb.__contains__(b"z") + MyBytes.__contains__ + False + """ + def __contains__(self, value): + print "MyBytes.__contains__" + return bytes.__contains__(self, value) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/tests/run/call_trace_gh4609.srctree new/Cython-0.29.30/tests/run/call_trace_gh4609.srctree --- old/Cython-0.29.28/tests/run/call_trace_gh4609.srctree 1970-01-01 01:00:00.000000000 +0100 +++ new/Cython-0.29.30/tests/run/call_trace_gh4609.srctree 2022-05-17 18:38:34.193270400 +0200 @@ -0,0 +1,44 @@ +PYTHON setup.py build_ext -i +PYTHON run.py + +######## setup.py ######## + +from Cython.Build.Dependencies import cythonize +from distutils.core import setup + +setup( + ext_modules = cythonize("*.pyx"), +) + +####### call_func.pyx ########## + +import mod + +def cy_method(x): + return mod.function(x) + +####### mod.py ################# + +mod_global = "this is a mod global" + +def function(a, mod_global=None): + if mod_global is not None: + mod_global = a + + return + +####### run.py ################# + +from call_func import cy_method +import mod +import sys + +def trace(frame, event, arg): + assert(mod.mod_global == "this is a mod global") + + return trace + +sys.settrace(trace) + +cy_method("s") +assert(mod.mod_global == "this is a mod global") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/tests/run/cpdef_enums.pyx new/Cython-0.29.30/tests/run/cpdef_enums.pyx --- old/Cython-0.29.28/tests/run/cpdef_enums.pyx 2022-02-17 00:58:31.563433600 +0100 +++ new/Cython-0.29.30/tests/run/cpdef_enums.pyx 2022-05-17 18:38:34.197270400 +0200 @@ -1,4 +1,6 @@ """ +>>> import sys + >>> ONE, TEN, HUNDRED (1, 10, 100) >>> THOUSAND # doctest: +ELLIPSIS @@ -35,8 +37,10 @@ >>> set(PyxEnum) == {TWO, THREE, FIVE} True ->>> str(PyxEnum.TWO).split(".")[-1] # Py3.10 changed the output here +>>> str(PyxEnum.TWO).split(".")[-1] if sys.version_info < (3,11) else "TWO" # Py3.10/11 changed the output here 'TWO' +>>> str(PyxEnum.TWO) if sys.version_info >= (3,11) else "2" # Py3.10/11 changed the output here +'2' >>> PyxEnum.TWO + PyxEnum.THREE == PyxEnum.FIVE True >>> PyxEnum(2) is PyxEnum["TWO"] is PyxEnum.TWO diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/tests/run/cyfunction.pyx new/Cython-0.29.30/tests/run/cyfunction.pyx --- old/Cython-0.29.28/tests/run/cyfunction.pyx 2022-02-17 00:58:31.567433600 +0100 +++ new/Cython-0.29.30/tests/run/cyfunction.pyx 2022-05-17 18:38:34.201270300 +0200 @@ -363,6 +363,9 @@ >>> C = TestUnboundMethodCdef >>> IS_PY2 or (C.meth is C.__dict__["meth"]) True + >>> TestUnboundMethodCdef.meth() # doctest:+ELLIPSIS + Traceback (most recent call last): + TypeError: ... """ def meth(self): pass @@ -372,6 +375,9 @@ >>> C = TestUnboundMethod >>> IS_PY2 or (C.meth is C.__dict__["meth"]) True + >>> TestUnboundMethod.meth() # doctest:+ELLIPSIS + Traceback (most recent call last): + TypeError: ... """ def meth(self): pass diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/tests/run/hasattr.pyx new/Cython-0.29.30/tests/run/hasattr.pyx --- old/Cython-0.29.28/tests/run/hasattr.pyx 2022-02-17 00:58:31.571433800 +0100 +++ new/Cython-0.29.30/tests/run/hasattr.pyx 2022-05-17 18:38:34.209270200 +0200 @@ -1,3 +1,5 @@ +# mode: run + class Foo: @property def foo(self): @@ -36,6 +38,6 @@ >>> hasattr(Foo(), None) #doctest: +ELLIPSIS Traceback (most recent call last): ... - TypeError: hasattr(): attribute name must be string + TypeError: ...attribute name must be string... """ return hasattr(obj, name) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/tests/run/modop.pyx new/Cython-0.29.30/tests/run/modop.pyx --- old/Cython-0.29.28/tests/run/modop.pyx 2022-02-17 00:58:31.575433700 +0100 +++ new/Cython-0.29.30/tests/run/modop.pyx 2022-05-17 18:38:34.213270400 +0200 @@ -9,7 +9,7 @@ '5' >>> modobj(1, 0) # doctest: +ELLIPSIS Traceback (most recent call last): - ZeroDivisionError: integer division... + ZeroDivisionError: integer ... """ obj1 = obj2 % obj3 return obj1 @@ -19,7 +19,7 @@ """ >>> mod_10_obj(0) # doctest: +ELLIPSIS Traceback (most recent call last): - ZeroDivisionError: integer division... + ZeroDivisionError: integer ... >>> mod_10_obj(3) 1 """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/tests/run/reduce_pickle.pyx new/Cython-0.29.30/tests/run/reduce_pickle.pyx --- old/Cython-0.29.28/tests/run/reduce_pickle.pyx 2022-02-17 00:58:31.579433700 +0100 +++ new/Cython-0.29.30/tests/run/reduce_pickle.pyx 2022-05-17 18:38:34.217270400 +0200 @@ -201,6 +201,16 @@ def __repr__(self): return "%s(ii=%s, x=%s)" % (type(self).__name__, self.ii, self.x) + def __eq__(self, other): + return ( + isinstance(other, NoPyMembers) and + (<NoPyMembers> other).ii[0] == self.ii[0] and + (<NoPyMembers> other).ii[1] == self.ii[1] and + (<NoPyMembers> other).ii[2] == self.ii[2] and + (<NoPyMembers> other).x == self.x + ) + + class NoPyMembersPySubclass(NoPyMembers): """ >>> import pickle @@ -304,3 +314,24 @@ """ def my_method(self, x): return x + + +# Pickled with Cython 0.29.28 (using MD5 for the checksum). +OLD_MD5_PICKLE = b'''\ +creduce_pickle\n__pyx_unpickle_NoPyMembers\nq\x00\ +(creduce_pickle\nNoPyMembers\nq\x01J\xf2K_\n(]q\x02\ +(K\x0bKyM3\x05eG?\xf8\x00\x00\x00\x00\x00\x00tq\x03tq\x04Rq\x05.\ +''' + +try: + from hashlib import md5 +except ImportError: + pass +else: + def unpickle_old_0_29_28(): + """ + >>> import pickle + >>> b = pickle.loads(OLD_MD5_PICKLE) + >>> b == NoPyMembers(i=11, x=1.5) or b + True + """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/tests/run/special_methods_T561.pyx new/Cython-0.29.30/tests/run/special_methods_T561.pyx --- old/Cython-0.29.28/tests/run/special_methods_T561.pyx 2022-02-17 00:58:31.579433700 +0100 +++ new/Cython-0.29.30/tests/run/special_methods_T561.pyx 2022-05-17 18:38:34.221270300 +0200 @@ -923,3 +923,27 @@ def __get__(self, inst, own): return VerySpecial.__get__(self, inst, own) + + +cdef class ReverseMethodsExist: + """ + reverse methods (such as __radd__) don't work in Cython <3. However, if they + are defined then it should be possible to look them up explicitly instead of + looking up autogenerated wrapper (which points to the forward method) + + >>> o = ReverseMethodsExist() + >>> o + o + 'add' + >>> o.__add__(o) + 'add' + >>> o.__radd__(o) + 'radd' + >>> o.__rsub__(o) + 'rsub' + """ + def __add__(self, other): + return "add" + def __radd__(self, other): + return "radd" + def __rsub__(self, other): + return "rsub" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/tests/run/test_unicode.pyx new/Cython-0.29.30/tests/run/test_unicode.pyx --- old/Cython-0.29.28/tests/run/test_unicode.pyx 2022-02-17 00:58:31.587433800 +0100 +++ new/Cython-0.29.30/tests/run/test_unicode.pyx 2022-05-17 18:38:34.221270300 +0200 @@ -1482,7 +1482,7 @@ self.assertEqual(('...%(foo)s...' % {'foo':Str.ABC}).replace("Str.", ""), '...ABC...') self.assertEqual(('...%(foo)s...' % {'foo':Int.IDES}).replace("Int.", ""), - '...IDES...') + '...IDES...' if sys.version_info < (3,11) else '...15...') self.assertEqual('...%(foo)i...' % {'foo':Int.IDES}, '...15...') self.assertEqual('...%(foo)d...' % {'foo':Int.IDES}, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/tests/run/tryexcept.pyx new/Cython-0.29.30/tests/run/tryexcept.pyx --- old/Cython-0.29.28/tests/run/tryexcept.pyx 2022-02-17 00:58:31.587433800 +0100 +++ new/Cython-0.29.30/tests/run/tryexcept.pyx 2022-05-17 18:38:34.225270300 +0200 @@ -501,3 +501,20 @@ else: i = 5 return i + + +def try_except_raise_new(initial, catch, throw): + """ + >>> try_except_raise_new(None, TypeError, ValueError) + >>> try_except_raise_new(TypeError, IndexError, ValueError) + Traceback (most recent call last): + TypeError + >>> try_except_raise_new(TypeError, TypeError, ValueError) + Traceback (most recent call last): + ValueError + """ + try: + if initial is not None: + raise initial + except catch: + raise throw diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.28/tests/run/tryfinally.pyx new/Cython-0.29.30/tests/run/tryfinally.pyx --- old/Cython-0.29.28/tests/run/tryfinally.pyx 2022-02-17 00:58:31.587433800 +0100 +++ new/Cython-0.29.30/tests/run/tryfinally.pyx 2022-05-17 18:38:34.225270300 +0200 @@ -549,3 +549,21 @@ del l[0], lobj[0] assert all(i == 3 for i in l), l return 99 + +def function_in_finally(): + """ + https://github.com/cython/cython/issues/4651 - function definitions in the + except copy of the finally clause weren't generated + + >>> function_in_finally() + in try + in func() + finished + """ + try: + print('in try') + finally: + def func(): + print('in func()') + func() + print('finished')