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 2023-01-14 20:31:22 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-Cython (Old) and /work/SRC/openSUSE:Factory/.python-Cython.new.32243 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-Cython" Sat Jan 14 20:31:22 2023 rev:68 rq:1058181 version:0.29.33 Changes: -------- --- /work/SRC/openSUSE:Factory/python-Cython/python-Cython.changes 2022-10-27 13:52:19.836007077 +0200 +++ /work/SRC/openSUSE:Factory/.python-Cython.new.32243/python-Cython.changes 2023-01-14 20:31:42.233207951 +0100 @@ -1,0 +2,31 @@ +Sat Jan 7 12:27:04 UTC 2023 - Dirk Müller <dmuel...@suse.com> + +- update to 0.29.33: + * The ``cythonize`` and ``cython`` commands have a new option ``-M`` / + ``--depfile`` to generate ``.dep`` dependency files for the + compilation unit. This can be used by external build tools to + track these dependencies. + * ``const`` fused types could not be used with memory views. + * ``wstr`` usage was removed in Python 3.12 and later (PEP-623). + * A type check assertion for Cython functions failed in debug Python + builds. + * Fixed various compiler warnings. + * Fixed error when calculating complex powers of negative numbers. + * Corrected a small mis-formatting of exception messages on Python 2. + * The ``PyUnicode_AsUTF8AndSize()`` C-API function was missing from the + CPython declarations. + * A performance problem in the compiler was resolved when nesting + conditional expressions. + * Test suite problems with recent NumPy and CPython versions were + resolved. + * Other changes + * The undocumented, untested and apparently useless syntax + ``from somemodule cimport class/struct/union somename`` was deprecated + in anticipation of its removal in Cython 3. The type + modifier is not needed here and a plain ``cimport`` of the name will do. + * Properly disable generation of descriptor docstrings on PyPy since they + cause crashes. + It was previously disabled, but only accidentally via a typo. + * The ``cpow`` directive of Cython 3.0 is available as a no-op. + +------------------------------------------------------------------- Old: ---- Cython-0.29.32.tar.gz New: ---- Cython-0.29.33.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-Cython.spec ++++++ --- /var/tmp/diff_new_pack.Dq4bVq/_old 2023-01-14 20:31:43.529215605 +0100 +++ /var/tmp/diff_new_pack.Dq4bVq/_new 2023-01-14 20:31:43.533215629 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-Cython # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %bcond_with test Name: python-Cython -Version: 0.29.32 +Version: 0.29.33 Release: 0 Summary: The Cython compiler for writing C extensions for the Python language License: Apache-2.0 ++++++ Cython-0.29.32.tar.gz -> Cython-0.29.33.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/.gitrev new/Cython-0.29.33/.gitrev --- old/Cython-0.29.32/.gitrev 2022-07-29 08:30:29.283721200 +0200 +++ new/Cython-0.29.33/.gitrev 2023-01-05 23:13:09.741008500 +0100 @@ -1 +1 @@ -c48361d0a0969206e227ec016f654c9d941c2b69 +d675bf287ba2b60c362a1fac80f8338565756675 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/CHANGES.rst new/Cython-0.29.33/CHANGES.rst --- old/Cython-0.29.32/CHANGES.rst 2022-07-29 08:30:24.199703500 +0200 +++ new/Cython-0.29.33/CHANGES.rst 2023-01-05 23:13:06.705019000 +0100 @@ -2,6 +2,65 @@ Cython Changelog ================ +0.29.33 (2023-01-06) +==================== + +Features added +-------------- + +* The ``cythonize`` and ``cython`` commands have a new option ``-M`` / ``--depfile`` + to generate ``.dep`` dependency files for the compilation unit. This can be used + by external build tools to track these dependencies. + The ``cythonize`` option was already available in Cython :ref:`0.29.27`. + Patches by Evgeni Burovski and Eli Schwartz. (Github issue :issue:`1214`) + +Bugs fixed +---------- + +* ``const`` fused types could not be used with memory views. + Patch by Thomas Vincent. (Github issue :issue:`1772`) + +* ``wstr`` usage was removed in Python 3.12 and later (PEP-623). + (Github issue :issue:`5145`) + +* A type check assertion for Cython functions failed in debug Python builds. + (Github issue :issue:`5031`) + +* Fixed various compiler warnings. + Patches by Lisandro Dalcin et al. (Github issues :issue:`4948`, :issue:`5086`) + +* Fixed error when calculating complex powers of negative numbers. + (Github issue :issue:`5014`) + +* Corrected a small mis-formatting of exception messages on Python 2. + (Github issue :issue:`5018`) + +* The ``PyUnicode_AsUTF8AndSize()`` C-API function was missing from the CPython declarations. + (Github issue :issue:`5163`) + +* A performance problem in the compiler was resolved when nesting conditional expressions. + (Github issue :issue:`5197`) + +* Test suite problems with recent NumPy and CPython versions were resolved. + (Github issues :issue:`5183`, :issue:`5190`) + +Other changes +------------- + +* The undocumented, untested and apparently useless syntax + ``from somemodule cimport class/struct/union somename`` was deprecated + in anticipation of its removal in Cython 3. The type + modifier is not needed here and a plain ``cimport`` of the name will do. + (Github issue :issue:`4905`) + +* Properly disable generation of descriptor docstrings on PyPy since they cause crashes. + It was previously disabled, but only accidentally via a typo. + Patch by Matti Picus. (Github issue :issue:`5083`) + +* The ``cpow`` directive of Cython 3.0 is available as a no-op. + (Github issue :issue:`5016`) + + 0.29.32 (2022-07-29) ==================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Build/Dependencies.py new/Cython-0.29.33/Cython/Build/Dependencies.py --- old/Cython-0.29.32/Cython/Build/Dependencies.py 2022-07-29 08:30:24.199703500 +0200 +++ new/Cython-0.29.33/Cython/Build/Dependencies.py 2023-01-05 23:13:06.705019000 +0100 @@ -43,7 +43,7 @@ pythran = None from .. import Utils -from ..Utils import (cached_function, cached_method, path_exists, +from ..Utils import (cached_function, cached_method, path_exists, write_depfile, safe_makedirs, copy_file_to_dir_if_newer, is_package_dir, replace_suffix) from ..Compiler.Main import Context, CompilationOptions, default_options @@ -1030,22 +1030,7 @@ # write out the depfile, if requested if depfile: dependencies = deps.all_dependencies(source) - src_base_dir, _ = os.path.split(source) - if not src_base_dir.endswith(os.sep): - src_base_dir += os.sep - # paths below the base_dir are relative, otherwise absolute - paths = [] - for fname in dependencies: - if (fname.startswith(src_base_dir) or - fname.startswith('.' + os.path.sep)): - paths.append(os.path.relpath(fname, src_base_dir)) - else: - paths.append(os.path.abspath(fname)) - - depline = os.path.split(c_file)[1] + ": \\\n " - depline += " \\\n ".join(paths) + "\n" - with open(c_file+'.dep', 'w') as outfile: - outfile.write(depline) + write_depfile(c_file, source, dependencies) if os.path.exists(c_file): c_timestamp = os.path.getmtime(c_file) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Compiler/CmdLine.py new/Cython-0.29.33/Cython/Compiler/CmdLine.py --- old/Cython-0.29.32/Cython/Compiler/CmdLine.py 2022-07-29 08:30:24.199703500 +0200 +++ new/Cython-0.29.33/Cython/Compiler/CmdLine.py 2023-01-05 23:13:06.709019000 +0100 @@ -53,6 +53,7 @@ --module-name Fully qualified module name. If not given, it is deduced from the import path if source file is in a package, or equals the filename otherwise. + -M, --depfile Produce depfiles for the sources """ @@ -66,7 +67,6 @@ sys.stderr.write(usage) sys.exit(1) - def parse_command_line(args): from .Main import CompilationOptions, default_options @@ -195,6 +195,8 @@ sys.exit(1) elif option == "--module-name": options.module_name = pop_value() + elif option in ('-M', '--depfile'): + options.depfile = True elif option.startswith('--debug'): option = option[2:].replace('-', '_') from . import DebugFlags @@ -236,4 +238,3 @@ "cython: Only one source file allowed when using --module-name\n") sys.exit(1) return options, sources - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Compiler/Code.py new/Cython-0.29.33/Cython/Compiler/Code.py --- old/Cython-0.29.32/Cython/Compiler/Code.py 2022-07-29 08:30:24.199703500 +0200 +++ new/Cython-0.29.33/Cython/Compiler/Code.py 2023-01-05 23:13:06.709019000 +0100 @@ -1559,7 +1559,7 @@ init_globals = self.parts['init_globals'] init_globals.putln( - "if (__Pyx_InitStrings(%s) < 0) %s;" % ( + "if (__Pyx_InitStrings(%s) < 0) %s" % ( Naming.stringtab_cname, init_globals.error_goto(self.module_pos))) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Compiler/ExprNodes.py new/Cython-0.29.33/Cython/Compiler/ExprNodes.py --- old/Cython-0.29.32/Cython/Compiler/ExprNodes.py 2022-07-29 08:30:24.203703600 +0200 +++ new/Cython-0.29.33/Cython/Compiler/ExprNodes.py 2023-01-05 23:13:06.709019000 +0100 @@ -11779,6 +11779,14 @@ class PowNode(NumBinopNode): # '**' operator. + def analyse_types(self, env): + if not env.directives['cpow']: + # Note - the check here won't catch cpow directives that don't use '**' + # but that's probably OK for a placeholder forward compatibility directive + error(self.pos, "The 'cpow' directive is provided for forward compatibility " + "and must be True") + return super(PowNode, self).analyse_types(env) + def analyse_c_operation(self, env): NumBinopNode.analyse_c_operation(self, env) if self.type.is_complex: @@ -12110,30 +12118,40 @@ return self.analyse_result_type(env) def analyse_result_type(self, env): - self.type = PyrexTypes.independent_spanning_type( - self.true_val.type, self.false_val.type) + true_val_type = self.true_val.type + false_val_type = self.false_val.type + self.type = PyrexTypes.independent_spanning_type(true_val_type, false_val_type) + if self.type.is_reference: self.type = PyrexTypes.CFakeReferenceType(self.type.ref_base_type) if self.type.is_pyobject: self.result_ctype = py_object_type elif self.true_val.is_ephemeral() or self.false_val.is_ephemeral(): error(self.pos, "Unsafe C derivative of temporary Python reference used in conditional expression") - if self.true_val.type.is_pyobject or self.false_val.type.is_pyobject: - self.true_val = self.true_val.coerce_to(self.type, env) - self.false_val = self.false_val.coerce_to(self.type, env) + + if true_val_type.is_pyobject or false_val_type.is_pyobject: + if true_val_type != self.type: + self.true_val = self.true_val.coerce_to(self.type, env) + if false_val_type != self.type: + self.false_val = self.false_val.coerce_to(self.type, env) + if self.type.is_error: self.type_error() return self def coerce_to_integer(self, env): - self.true_val = self.true_val.coerce_to_integer(env) - self.false_val = self.false_val.coerce_to_integer(env) + if not self.true_val.type.is_int: + self.true_val = self.true_val.coerce_to_integer(env) + if not self.false_val.type.is_int: + self.false_val = self.false_val.coerce_to_integer(env) self.result_ctype = None return self.analyse_result_type(env) def coerce_to(self, dst_type, env): - self.true_val = self.true_val.coerce_to(dst_type, env) - self.false_val = self.false_val.coerce_to(dst_type, env) + if self.true_val.type != dst_type: + self.true_val = self.true_val.coerce_to(dst_type, env) + if self.false_val.type != dst_type: + self.false_val = self.false_val.coerce_to(dst_type, env) self.result_ctype = None return self.analyse_result_type(env) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Compiler/Main.py new/Cython-0.29.33/Cython/Compiler/Main.py --- old/Cython-0.29.32/Cython/Compiler/Main.py 2022-07-29 08:30:24.203703600 +0200 +++ new/Cython-0.29.33/Cython/Compiler/Main.py 2023-01-05 23:13:06.713019000 +0100 @@ -514,6 +514,10 @@ context.setup_errors(options, result) err, enddata = Pipeline.run_pipeline(pipeline, source) context.teardown_errors(err, options, result) + if options.depfile: + from ..Build.Dependencies import create_dependency_tree + dependencies = create_dependency_tree(context).all_dependencies(result.main_source_file) + Utils.write_depfile(result.c_file, result.main_source_file, dependencies) return result @@ -881,6 +885,7 @@ errors_to_stderr = 1, cplus = 0, output_file = None, + depfile = None, annotate = None, annotate_coverage_xml = None, generate_pxi = 0, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Compiler/ModuleNode.py new/Cython-0.29.33/Cython/Compiler/ModuleNode.py --- old/Cython-0.29.32/Cython/Compiler/ModuleNode.py 2022-07-29 08:30:24.207703600 +0200 +++ new/Cython-0.29.33/Cython/Compiler/ModuleNode.py 2023-01-05 23:13:06.713019000 +0100 @@ -2491,7 +2491,7 @@ if Options.generate_cleanup_code: code.globalstate.use_utility_code( UtilityCode.load_cached("RegisterModuleCleanup", "ModuleSetupCode.c")) - code.putln("if (__Pyx_RegisterCleanup()) %s;" % code.error_goto(self.pos)) + code.putln("if (__Pyx_RegisterCleanup()) %s" % code.error_goto(self.pos)) code.put_goto(code.return_label) code.put_label(code.error_label) @@ -2835,7 +2835,7 @@ 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;' % ( + 'if (PyObject_SetAttrString(%s, "__builtins__", %s) < 0) %s' % ( env.module_cname, Naming.builtins_cname, code.error_goto(self.pos))) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Compiler/Options.py new/Cython-0.29.33/Cython/Compiler/Options.py --- old/Cython-0.29.32/Cython/Compiler/Options.py 2022-07-29 08:30:24.207703600 +0200 +++ new/Cython-0.29.33/Cython/Compiler/Options.py 2023-01-05 23:13:06.717019000 +0100 @@ -179,6 +179,7 @@ 'cdivision': False, # was True before 0.12 'cdivision_warnings': False, 'c_api_binop_methods': True, + 'cpow': True, 'overflowcheck': False, 'overflowcheck.fold': True, 'always_allow_keywords': False, @@ -318,6 +319,7 @@ 'freelist': int, 'c_string_type': one_of('bytes', 'bytearray', 'str', 'unicode'), 'c_string_encoding': normalise_encoding_name, + 'cpow': bool } for key, val in _directive_defaults.items(): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Compiler/Parsing.py new/Cython-0.29.33/Cython/Compiler/Parsing.py --- old/Cython-0.29.32/Cython/Compiler/Parsing.py 2022-07-29 08:30:24.211703500 +0200 +++ new/Cython-0.29.33/Cython/Compiler/Parsing.py 2023-01-05 23:13:06.717019000 +0100 @@ -1795,6 +1795,8 @@ kind = None if is_cimport and s.systring in imported_name_kinds: kind = s.systring + warning(pos, 'the "from module cimport %s name" syntax is deprecated and ' + 'will be removed in Cython 3.0' % kind, 2) s.next() name = p_ident(s) as_name = p_as_name(s) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Compiler/PyrexTypes.py new/Cython-0.29.33/Cython/Compiler/PyrexTypes.py --- old/Cython-0.29.32/Cython/Compiler/PyrexTypes.py 2022-07-29 08:30:24.211703500 +0200 +++ new/Cython-0.29.33/Cython/Compiler/PyrexTypes.py 2023-01-05 23:13:06.717019000 +0100 @@ -1297,7 +1297,7 @@ name = '"%s"' % self.name # avoid wasting too much space but limit number of different format strings space_for_name = (len(self.name) // 16 + 1) * 16 - error = '(PyErr_Format(PyExc_TypeError, "Expected %%.%ds, got %%.200s", %s, Py_TYPE(%s)->tp_name), 0)' % ( + error = '((void)PyErr_Format(PyExc_TypeError, "Expected %%.%ds, got %%.200s", %s, Py_TYPE(%s)->tp_name), 0)' % ( space_for_name, name, arg) return check + '||' + error @@ -1561,6 +1561,7 @@ class CConstType(BaseType): is_const = 1 + subtypes = ['const_base_type'] def __init__(self, const_base_type): self.const_base_type = const_base_type diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Includes/cpython/unicode.pxd new/Cython-0.29.33/Cython/Includes/cpython/unicode.pxd --- old/Cython-0.29.32/Cython/Includes/cpython/unicode.pxd 2022-07-29 08:30:24.219703700 +0200 +++ new/Cython-0.29.33/Cython/Includes/cpython/unicode.pxd 2023-01-05 23:13:06.725019000 +0100 @@ -314,9 +314,25 @@ # raised by the codec. bytes PyUnicode_EncodeUTF8(Py_UNICODE *s, Py_ssize_t size, char *errors) - # Encode a Unicode objects using UTF-8 and return the result as Python string object. Error handling is ``strict''. Return NULL if an exception was raised by the codec. + # Encode a Unicode objects using UTF-8 and return the result as Python bytes object. Error handling is ``strict''. Return NULL if an exception was raised by the codec. bytes PyUnicode_AsUTF8String(object unicode) + + # Return a pointer to the UTF-8 encoding of the Unicode object, + # and store the size of the encoded representation (in bytes) in size. + # The size argument can be NULL; in this case no size will be stored. + # The returned buffer always has an extra null byte appended + # (not included in size), regardless of whether there are any + # other null code points. + + # In the case of an error, NULL is returned with an exception set and + # no size is stored. + + # This caches the UTF-8 representation of the string in the Unicode + # object, and subsequent calls will return a pointer to the same buffer. + # The caller is not responsible for deallocating the buffer + const char* PyUnicode_AsUTF8AndSize(object unicode, Py_ssize_t *size) + # These are the UTF-16 codec APIs: # Decode length bytes from a UTF-16 encoded buffer string and diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Shadow.py new/Cython-0.29.33/Cython/Shadow.py --- old/Cython-0.29.32/Cython/Shadow.py 2022-07-29 08:30:24.223703600 +0200 +++ new/Cython-0.29.33/Cython/Shadow.py 2023-01-05 23:13:06.725019000 +0100 @@ -1,7 +1,7 @@ # cython.* namespace for pure mode. from __future__ import absolute_import -__version__ = "0.29.32" +__version__ = "0.29.33" try: from __builtin__ import basestring diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Utility/Complex.c new/Cython-0.29.33/Cython/Utility/Complex.c --- old/Cython-0.29.32/Cython/Utility/Complex.c 2022-07-29 08:30:24.223703600 +0200 +++ new/Cython-0.29.33/Cython/Utility/Complex.c 2023-01-05 23:13:06.729019000 +0100 @@ -265,7 +265,7 @@ if (a.imag == 0) { if (a.real == 0) { return a; - } else if (b.imag == 0) { + } else if ((b.imag == 0) && (a.real >= 0)) { z.real = pow{{m}}(a.real, b.real); z.imag = 0; return z; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Utility/CythonFunction.c new/Cython-0.29.33/Cython/Utility/CythonFunction.c --- old/Cython-0.29.32/Cython/Utility/CythonFunction.c 2022-07-29 08:30:24.227703600 +0200 +++ new/Cython-0.29.33/Cython/Utility/CythonFunction.c 2023-01-05 23:13:06.729019000 +0100 @@ -660,9 +660,17 @@ self = PyTuple_GetItem(args, 0); if (unlikely(!self)) { Py_DECREF(new_args); +#if PY_MAJOR_VERSION > 2 PyErr_Format(PyExc_TypeError, "unbound method %.200S() needs an argument", cyfunc->func_qualname); +#else + // %S doesn't work in PyErr_Format on Py2 and replicating + // the formatting seems more trouble than it's worth + // (so produce a less useful error message). + PyErr_SetString(PyExc_TypeError, + "unbound method needs an argument"); +#endif return NULL; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Utility/Exceptions.c new/Cython-0.29.33/Cython/Utility/Exceptions.c --- old/Cython-0.29.32/Cython/Utility/Exceptions.c 2022-07-29 08:30:24.227703600 +0200 +++ new/Cython-0.29.33/Cython/Utility/Exceptions.c 2023-01-05 23:13:06.729019000 +0100 @@ -600,10 +600,8 @@ PyGILState_STATE state; if (nogil) state = PyGILState_Ensure(); -#ifdef _MSC_VER - /* arbitrary, to suppress warning */ - else state = (PyGILState_STATE)-1; -#endif + /* initalize to suppress warning */ + else state = (PyGILState_STATE)0; #endif __Pyx_PyThreadState_assign __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); @@ -647,7 +645,7 @@ //@substitute: naming #ifndef CYTHON_CLINE_IN_TRACEBACK -static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) { +static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) { PyObject *use_cline; PyObject *ptype, *pvalue, *ptraceback; #if CYTHON_COMPILING_IN_CPYTHON diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Utility/ModuleSetupCode.c new/Cython-0.29.33/Cython/Utility/ModuleSetupCode.c --- old/Cython-0.29.32/Cython/Utility/ModuleSetupCode.c 2022-07-29 08:30:24.227703600 +0200 +++ new/Cython-0.29.33/Cython/Utility/ModuleSetupCode.c 2023-01-05 23:13:06.729019000 +0100 @@ -85,7 +85,7 @@ #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) + #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #elif defined(PYSTON_VERSION) @@ -664,12 +664,12 @@ #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 - #if defined(PyUnicode_IS_READY) - #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ - 0 : _PyUnicode_Ready((PyObject *)(op))) + #if PY_VERSION_HEX >= 0x030C0000 + // Py3.12 / PEP-623 removed wstr type unicode strings and all of the PyUnicode_READY() machinery. + #define __Pyx_PyUnicode_READY(op) (0) #else - // Py3.12 / PEP-623 will remove wstr type unicode strings and all of the PyUnicode_READY() machinery. - #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ + 0 : _PyUnicode_Ready((PyObject *)(op))) #endif #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) @@ -679,16 +679,16 @@ #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) - #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE) - #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 - // Avoid calling deprecated C-API functions in Py3.9+ that PEP-623 schedules for removal in Py3.12. - // https://www.python.org/dev/peps/pep-0623/ - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) - #else - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) - #endif + #if PY_VERSION_HEX >= 0x030C0000 + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) #else - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 + // Avoid calling deprecated C-API functions in Py3.9+ that PEP-623 schedules for removal in Py3.12. + // https://www.python.org/dev/peps/pep-0623/ + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) + #else + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) + #endif #endif #else #define CYTHON_PEP393_ENABLED 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Utility/ObjectHandling.c new/Cython-0.29.33/Cython/Utility/ObjectHandling.c --- old/Cython-0.29.32/Cython/Utility/ObjectHandling.c 2022-07-29 08:30:24.227703600 +0200 +++ new/Cython-0.29.33/Cython/Utility/ObjectHandling.c 2023-01-05 23:13:06.729019000 +0100 @@ -72,10 +72,9 @@ Py_DECREF(retval); __Pyx_RaiseTooManyValuesError(expected); return -1; - } else { - return __Pyx_IterFinish(); } - return 0; + + return __Pyx_IterFinish(); } /////////////// UnpackTuple2.proto /////////////// @@ -285,7 +284,7 @@ #if CYTHON_USE_TYPE_SLOTS static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) { - PyObject *runerr; + PyObject *runerr = NULL; Py_ssize_t key_value; PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence; if (unlikely(!(m && m->sq_item))) { @@ -1169,18 +1168,18 @@ //@substitute: naming #if CYTHON_USE_DICT_VERSIONS -#define __Pyx_GetModuleGlobalName(var, name) { \ +#define __Pyx_GetModuleGlobalName(var, name) do { \ static PY_UINT64_T __pyx_dict_version = 0; \ static PyObject *__pyx_dict_cached_value = NULL; \ (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION($moddict_cname))) ? \ (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) : \ __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value); \ -} -#define __Pyx_GetModuleGlobalNameUncached(var, name) { \ +} while(0) +#define __Pyx_GetModuleGlobalNameUncached(var, name) do { \ PY_UINT64_T __pyx_dict_version; \ PyObject *__pyx_dict_cached_value; \ (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value); \ -} +} while(0) static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); /*proto*/ #else #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) @@ -1668,11 +1667,11 @@ if (flag == METH_O) { return (*(cfunc->func))(self, arg); } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) { - if (PY_VERSION_HEX >= 0x030700A0) { + #if PY_VERSION_HEX >= 0x030700A0 return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, &arg, 1); - } else { + #else return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL); - } + #endif } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) { return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL); } @@ -2322,7 +2321,10 @@ return __Pyx_PyFunction_FastCall(func, NULL, 0); } #endif -#ifdef __Pyx_CyFunction_USED +#if defined(__Pyx_CyFunction_USED) && defined(NDEBUG) + // TODO PyCFunction_GET_FLAGS has a type-check assert that breaks with a CyFunction + // in debug mode. There is likely to be a better way of avoiding tripping this + // check that doesn't involve disabling the optimized path. if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func))) #else if (likely(PyCFunction_Check(func))) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Cython/Utils.py new/Cython-0.29.33/Cython/Utils.py --- old/Cython-0.29.32/Cython/Utils.py 2022-07-29 08:30:24.227703600 +0200 +++ new/Cython-0.29.33/Cython/Utils.py 2023-01-05 23:13:06.733018900 +0100 @@ -447,3 +447,24 @@ hexversion = (hexversion << 8) + digit return '0x%08X' % hexversion + + +def write_depfile(target, source, dependencies): + src_base_dir = os.path.dirname(source) + cwd = os.getcwd() + if not src_base_dir.endswith(os.sep): + src_base_dir += os.sep + # paths below the base_dir are relative, otherwise absolute + paths = [] + for fname in dependencies: + fname = os.path.abspath(fname) + if fname.startswith(src_base_dir): + paths.append(os.path.relpath(fname, cwd)) + else: + paths.append(fname) + + depline = os.path.relpath(target, cwd) + ": \\\n " + depline += " \\\n ".join(paths) + "\n" + + with open(target+'.dep', 'w') as outfile: + outfile.write(depline) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/MANIFEST.in new/Cython-0.29.33/MANIFEST.in --- old/Cython-0.29.32/MANIFEST.in 2022-07-29 08:30:24.231703800 +0200 +++ new/Cython-0.29.33/MANIFEST.in 2023-01-05 23:13:06.733018900 +0100 @@ -2,6 +2,7 @@ include COPYING.txt LICENSE.txt Makefile include .gitrev include pylintrc +include tox.ini include setup.py include setupegg.py include bin/* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/PKG-INFO new/Cython-0.29.33/PKG-INFO --- old/Cython-0.29.32/PKG-INFO 2022-07-29 08:30:35.943727300 +0200 +++ new/Cython-0.29.33/PKG-INFO 2023-01-05 23:13:15.065041300 +0100 @@ -1,11 +1,16 @@ Metadata-Version: 2.1 Name: Cython -Version: 0.29.32 +Version: 0.29.33 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 +Project-URL: Documentation, https://cython.readthedocs.io/ +Project-URL: Donate, https://cython.readthedocs.io/en/latest/src/donating.html +Project-URL: Source Code, https://github.com/cython/cython +Project-URL: Bug Tracker, https://github.com/cython/cython/issues +Project-URL: User Group, https://groups.google.com/g/cython-users Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Apache Software License diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/Tools/ci-run.sh new/Cython-0.29.33/Tools/ci-run.sh --- old/Cython-0.29.32/Tools/ci-run.sh 2022-07-29 08:30:24.231703800 +0200 +++ new/Cython-0.29.33/Tools/ci-run.sh 2023-01-05 23:13:06.733018900 +0100 @@ -109,6 +109,16 @@ # to override the previous ones, so '-O0 -O3' == '-O3' # This is true for the latest msvc, gcc and clang CFLAGS="-O0 -ggdb -Wall -Wextra" +# Trying to cover debug assertions in the CI without adding +# extra jobs. Therefore, odd-numbered minor versions of Python +# running C++ jobs get NDEBUG undefined, and even-numbered +# versions running C jobs get NDEBUG undefined. +ODD_VERSION=$(python3 -c "import sys; print(sys.version_info[1]%2)") +if [[ $BACKEND == *"cpp"* && $ODD_VERSION == "1" ]]; then + CFLAGS="$CFLAGS -UNDEBUG" +elif [[ $ODD_VERSION == "0" ]]; then + CFLAGS="$CFLAGS -UNDEBUG" +fi if [[ $NO_CYTHON_COMPILE != "1" && $PYTHON_VERSION != "pypy"* ]]; then diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/setup.py new/Cython-0.29.33/setup.py --- old/Cython-0.29.32/setup.py 2022-07-29 08:30:24.251703700 +0200 +++ new/Cython-0.29.33/setup.py 2023-01-05 23:13:06.749019000 +0100 @@ -282,6 +282,13 @@ "Topic :: Software Development :: Compilers", "Topic :: Software Development :: Libraries :: Python Modules" ], + project_urls={ + "Documentation": "https://cython.readthedocs.io/", + "Donate": "https://cython.readthedocs.io/en/latest/src/donating.html", + "Source Code": "https://github.com/cython/cython", + "Bug Tracker": "https://github.com/cython/cython/issues", + "User Group": "https://groups.google.com/g/cython-users", + }, scripts=scripts, packages=packages, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/tests/build/depfile_package.srctree new/Cython-0.29.33/tests/build/depfile_package.srctree --- old/Cython-0.29.32/tests/build/depfile_package.srctree 2022-07-29 08:30:24.251703700 +0200 +++ new/Cython-0.29.33/tests/build/depfile_package.srctree 1970-01-01 01:00:00.000000000 +0100 @@ -1,57 +0,0 @@ -""" -PYTHON -m Cython.Build.Cythonize -i pkg --depfile -PYTHON package_test.py -""" - -######## package_test.py ######## - -import os.path - -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(os.path.join("pkg", "sub", "test.c.dep"), "r") as f: - contents = f.read().replace("\\\n", " ").replace("\n", " ") - -contents = [os.path.relpath(entry, '.') - if os.path.isabs(entry) else entry for entry in contents.split()] -assert sorted(contents) == sorted(['test.c:', 'incl.pxi', 'test.pyx', os.path.join('..', 'test.pxd')]), contents - - -######## pkg/__init__.py ######## - - -######## pkg/test.pyx ######## - -TEST = "pkg.test" - -include "sub/incl.pxi" - -cdef object get_str(): - return TEST - - -######## pkg/test.pxd ######## - -cdef object get_str() - - -######## pkg/sub/__init__.py ######## - - -######## pkg/sub/test.pyx ######## -# cython: language_level=3 - -from ..test cimport get_str - -include 'incl.pxi' - -TEST = 'pkg.sub.test' - - -######## pkg/sub/incl.pxi ######## - -pass diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/tests/build/depfile_package_cython.srctree new/Cython-0.29.33/tests/build/depfile_package_cython.srctree --- old/Cython-0.29.32/tests/build/depfile_package_cython.srctree 1970-01-01 01:00:00.000000000 +0100 +++ new/Cython-0.29.33/tests/build/depfile_package_cython.srctree 2023-01-05 23:13:06.749019000 +0100 @@ -0,0 +1,61 @@ +""" +PYTHON -c 'import os; os.makedirs("builddir/pkg/sub")' +CYTHON -M pkg/test.pyx -o builddir/pkg/test.c +CYTHON --depfile pkg/sub/test.pyx -o builddir/pkg/sub/test.c +PYTHON check.py +""" + +######## check.py ######## + +import os.path + +def pkgpath(*args): + return os.path.join('pkg', *args) + +with open(os.path.join("builddir", "pkg", "test.c.dep"), "r") as f: + contents = f.read().replace("\\\n", " ").replace("\n", " ") + +assert sorted(contents.split()) == sorted([os.path.join('builddir', 'pkg', 'test.c:'), pkgpath('sub', 'incl.pxi'), pkgpath('test.pxd'), pkgpath('test.pyx')]), contents + + +with open(os.path.join("builddir", "pkg", "sub", "test.c.dep"), "r") as f: + contents = f.read().replace("\\\n", " ").replace("\n", " ") + +contents = [os.path.relpath(entry, '.') + if os.path.isabs(entry) else entry for entry in contents.split()] +assert sorted(contents) == sorted([os.path.join('builddir', 'pkg', 'sub', 'test.c:'), pkgpath('sub', 'incl.pxi'), pkgpath('sub', 'test.pyx')]), contents # last is really one level up + +######## pkg/__init__.py ######## + + +######## pkg/test.pyx ######## + +TEST = "pkg.test" + +include "sub/incl.pxi" + +cdef object get_str(): + return TEST + + +######## pkg/test.pxd ######## + +cdef object get_str() + + +######## pkg/sub/__init__.py ######## + + +######## pkg/sub/test.pyx ######## +# cython: language_level=3 + +from ..test cimport get_str + +include 'incl.pxi' + +TEST = 'pkg.sub.test' + + +######## pkg/sub/incl.pxi ######## + +pass diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/tests/build/depfile_package_cythonize.srctree new/Cython-0.29.33/tests/build/depfile_package_cythonize.srctree --- old/Cython-0.29.32/tests/build/depfile_package_cythonize.srctree 1970-01-01 01:00:00.000000000 +0100 +++ new/Cython-0.29.33/tests/build/depfile_package_cythonize.srctree 2023-01-05 23:13:06.749019000 +0100 @@ -0,0 +1,60 @@ +""" +PYTHON -m Cython.Build.Cythonize -i pkg --depfile +PYTHON package_test.py +""" + +######## package_test.py ######## + +import os.path + +def pkgpath(*args): + return os.path.join('pkg', *args) + +with open(os.path.join("pkg", "test.c.dep"), "r") as f: + contents = f.read().replace("\\\n", " ").replace("\n", " ") + +assert sorted(contents.split()) == sorted([pkgpath('test.c:'), pkgpath('sub', 'incl.pxi'), pkgpath('test.pxd'), pkgpath('test.pyx')]), contents + + +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, '.') + if os.path.isabs(entry) else entry for entry in contents.split()] +assert sorted(contents) == sorted([pkgpath('sub', 'test.c:'), pkgpath('sub', 'incl.pxi'), pkgpath('sub', 'test.pyx'), pkgpath('test.pxd')]), contents # last is really one level up + + +######## pkg/__init__.py ######## + + +######## pkg/test.pyx ######## + +TEST = "pkg.test" + +include "sub/incl.pxi" + +cdef object get_str(): + return TEST + + +######## pkg/test.pxd ######## + +cdef object get_str() + + +######## pkg/sub/__init__.py ######## + + +######## pkg/sub/test.pyx ######## +# cython: language_level=3 + +from ..test cimport get_str + +include 'incl.pxi' + +TEST = 'pkg.sub.test' + + +######## pkg/sub/incl.pxi ######## + +pass diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/tests/errors/fused_types.pyx new/Cython-0.29.33/tests/errors/fused_types.pyx --- old/Cython-0.29.32/tests/errors/fused_types.pyx 2022-07-29 08:30:24.267704000 +0200 +++ new/Cython-0.29.33/tests/errors/fused_types.pyx 2023-01-05 23:13:06.761018800 +0100 @@ -1,4 +1,5 @@ # mode: error +# ticket: 1772 cimport cython from cython import fused_type @@ -64,17 +65,30 @@ func(x, y) +cdef fused mix_const_t: + int + const int + +cdef cdef_func_with_mix_const_type(mix_const_t val): + print(val) + +# Mixing const and non-const type makes fused type ambiguous +cdef_func_with_mix_const_type(1) + + _ERRORS = u""" -10:15: fused_type does not take keyword arguments -15:33: Type specified multiple times -26:0: Invalid use of fused types, type cannot be specialized -26:4: Not enough types specified to specialize the function, int2_t is still fused +11:15: fused_type does not take keyword arguments +16:33: Type specified multiple times 27:0: Invalid use of fused types, type cannot be specialized 27:4: Not enough types specified to specialize the function, int2_t is still fused -28:16: Call with wrong number of arguments (expected 2, got 1) -29:16: Call with wrong number of arguments (expected 2, got 3) -36:6: Invalid base type for memoryview slice: int * -39:0: Fused lambdas not allowed -42:5: Fused types not allowed here -45:9: Fused types not allowed here +28:0: Invalid use of fused types, type cannot be specialized +28:4: Not enough types specified to specialize the function, int2_t is still fused +29:16: Call with wrong number of arguments (expected 2, got 1) +30:16: Call with wrong number of arguments (expected 2, got 3) +37:6: Invalid base type for memoryview slice: int * +40:0: Fused lambdas not allowed +43:5: Fused types not allowed here +46:9: Fused types not allowed here +76:0: Invalid use of fused types, type cannot be specialized +76:29: ambiguous overloaded method """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/tests/memoryview/numpy_memoryview_readonly.pyx new/Cython-0.29.33/tests/memoryview/numpy_memoryview_readonly.pyx --- old/Cython-0.29.32/tests/memoryview/numpy_memoryview_readonly.pyx 2022-07-29 08:30:24.271704000 +0200 +++ new/Cython-0.29.33/tests/memoryview/numpy_memoryview_readonly.pyx 2023-01-05 23:13:06.761018800 +0100 @@ -1,10 +1,14 @@ # mode: run # tag: readonly, const, numpy +# ticket: 1772 import numpy as np +cimport cython -def new_array(): - return np.arange(10).astype('float') +def new_array(dtype='float', writeable=True): + array = np.arange(10, dtype=dtype) + array.setflags(write=writeable) + return array ARRAY = new_array() @@ -124,3 +128,45 @@ rw[1] = 2 rw2[2] = 2 return rw[0], rw[1], rw[2], rw2[0], rw2[1], rw2[2] + + +cdef getmax_floating(const cython.floating[:] x): + """Function with fused type, should work with both ro and rw memoryviews""" + cdef cython.floating max_val = - float('inf') + for val in x: + if val > max_val: + max_val = val + return max_val + + +def test_mmview_const_fused_cdef(): + """Test cdef function with const fused type memory view as argument. + + >>> test_mmview_const_fused_cdef() + """ + cdef float[:] data_rw = new_array(dtype='float32') + assert getmax_floating(data_rw) == 9 + + cdef const float[:] data_ro = new_array(dtype='float32', writeable=False) + assert getmax_floating(data_ro) == 9 + + +def test_mmview_const_fused_def(const cython.floating[:] x): + """Test def function with const fused type memory view as argument. + + With read-write numpy array: + + >>> test_mmview_const_fused_def(new_array('float32', writeable=True)) + 0.0 + >>> test_mmview_const_fused_def(new_array('float64', writeable=True)) + 0.0 + + With read-only numpy array: + + >>> test_mmview_const_fused_def(new_array('float32', writeable=False)) + 0.0 + >>> test_mmview_const_fused_def(new_array('float64', writeable=False)) + 0.0 + """ + cdef cython.floating result = x[0] + return result diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/tests/run/asyncio_generators.srctree new/Cython-0.29.33/tests/run/asyncio_generators.srctree --- old/Cython-0.29.32/tests/run/asyncio_generators.srctree 2022-07-29 08:30:24.271704000 +0200 +++ new/Cython-0.29.33/tests/run/asyncio_generators.srctree 2023-01-05 23:13:06.765019000 +0100 @@ -24,13 +24,15 @@ import from_asyncio_import import asyncio +import sys +from contextlib import closing +new_event_loop = asyncio.new_event_loop if sys.version_info >= (3, 5) else asyncio.get_event_loop def runloop(task): - loop = asyncio.get_event_loop() - result = loop.run_until_complete(task()) - assert 3 == result, result + with closing(new_event_loop()) as loop: + result = loop.run_until_complete(task()) + assert 3 == result, result -import sys if sys.version_info < (3, 7): runloop(from_asyncio_import.wait3) @@ -39,13 +41,15 @@ import import_asyncio import asyncio +import sys +from contextlib import closing +new_event_loop = asyncio.new_event_loop if sys.version_info >= (3, 5) else asyncio.get_event_loop def runloop(task): - loop = asyncio.get_event_loop() - result = loop.run_until_complete(task()) - assert 3 == result, result + with closing(new_event_loop()) as loop: + result = loop.run_until_complete(task()) + assert 3 == result, result -import sys if sys.version_info < (3, 7): runloop(import_asyncio.wait3) @@ -59,11 +63,12 @@ if ASYNCIO_SUPPORTS_COROUTINE: import async_def import asyncio + from contextlib import closing def runloop(task): - loop = asyncio.get_event_loop() - result = loop.run_until_complete(task()) - assert 3 == result, result + with closing(asyncio.new_event_loop()) as loop: + result = loop.run_until_complete(task()) + assert 3 == result, result runloop(async_def.wait3) @@ -77,12 +82,13 @@ if ASYNCIO_SUPPORTS_COROUTINE: from async_def_future import await_future import asyncio + from contextlib import closing def runloop(): - loop = asyncio.get_event_loop() - task, events, expected = await_future(loop) - result = loop.run_until_complete(task()) - assert events == expected, 'expected %s, got %s' % (expected, events) + with closing(asyncio.new_event_loop()) as loop: + task, events, expected = await_future(loop) + result = loop.run_until_complete(task()) + assert events == expected, 'expected %s, got %s' % (expected, events) runloop() @@ -91,14 +97,22 @@ import sys import asyncio +from contextlib import closing, contextmanager +new_event_loop = asyncio.new_event_loop if sys.version_info >= (3, 5) else asyncio.get_event_loop +if sys.version_info < (3, 5): + # don't close loop on Py 3.4 + @contextmanager + def closing(o): + yield o + ASYNCIO_SUPPORTS_COROUTINE = sys.version_info[:2] >= (3, 5) ASYNCIO_SUPPORTS_YIELD_FROM = sys.version_info[:2] < (3, 7) def runloop(task): - loop = asyncio.get_event_loop() - result = loop.run_until_complete(task()) - assert 3 == result, result + with closing(new_event_loop()) as loop: + result = loop.run_until_complete(task()) + assert 3 == result, result import import_asyncio if ASYNCIO_SUPPORTS_YIELD_FROM: @@ -130,7 +144,7 @@ try: from collections import Generator except ImportError: - assert sys.version_info < (3,5), "Python 3.5+ should have collections.abc.Generator" + assert sys.version_info < (3, 5), "Python 3.5+ should have collections.abc.Generator" Generator = object # easy win :) assert isinstance(from_asyncio_import.wait3(), Generator) @@ -143,7 +157,7 @@ try: from collections import Awaitable except ImportError: - assert sys.version_info < (3,5), "Python 3.5+ should have collections.abc.Awaitable" + assert sys.version_info < (3, 5), "Python 3.5+ should have collections.abc.Awaitable" Awaitable = object # easy win :) assert isinstance(async_def.wait3(), Awaitable) @@ -154,7 +168,7 @@ try: from collections import Coroutine except ImportError: - assert sys.version_info < (3,5), "Python 3.5+ should have collections.abc.Coroutine" + assert sys.version_info < (3, 5), "Python 3.5+ should have collections.abc.Coroutine" Coroutine = object # easy win :) assert isinstance(async_def.wait3(), Coroutine) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/tests/run/complex_numbers_T305.pyx new/Cython-0.29.33/tests/run/complex_numbers_T305.pyx --- old/Cython-0.29.32/tests/run/complex_numbers_T305.pyx 2022-07-29 08:30:24.279704000 +0200 +++ new/Cython-0.29.33/tests/run/complex_numbers_T305.pyx 2023-01-05 23:13:06.769019000 +0100 @@ -80,6 +80,8 @@ True >>> test_pow(-0.5, 1j, tol=1e-15) True + >>> test_pow(-1, 0.5, tol=1e-15) + True """ if tol is None: return z**w @@ -264,3 +266,87 @@ 1j """ return 1j + +def stress_test(): + """ + Run the main operations on 1000 pseudo-random numbers to + try to spot anything accidentally missed from the test cases + (doesn't cover inf and NaN as inputs though) + >>> stress_test() + """ + cdef double complex x + cdef double complex y + + from random import Random + from math import ldexp + r = Random() + r.seed("I'm a seed") # try to make the test somewhat reproducible + + # copied from https://docs.python.org/3/library/random.html#recipes + # gets evenly distributed random numbers + def full_random(): + mantissa = 0x10_0000_0000_0000 | r.getrandbits(52) + exponent = -53 + x = 0 + while not x: + x = r.getrandbits(32) + exponent += x.bit_length() - 32 + return ldexp(mantissa, exponent) + + for n in range(1, 1001): + if n % 50 == 0: + # strategical insert some 0 values + a = 0 + else: + a = full_random() + if n % 51 == 0: + b = 0 + else: + b = full_random() + if n % 52 == 0: + c = 0 + else: + c = full_random() + if n % 53 == 0: + d = 0 + else: + d = full_random() + + x= a+1j*b + y = c+1j*d + py_dict = dict(x=x, y=y) + + sum_ = x+y + sum_py = eval("x+y", py_dict) + delta_sum = abs(sum_/sum_py - 1) + assert delta_sum < 1e-15, f"{x} {y} {sum_} {sum_py} {delta_sum}" + + minus = x-y + minus_py = eval("x-y", py_dict) + delta_minus = abs(minus/minus_py - 1) + assert delta_minus < 1e-15, f"{x} {y} {minus} {minus_py} {delta_minus}" + + times = x*y + times_py = eval("x*y", py_dict) + delta_times = abs(times/times_py - 1) + assert delta_times < 1e-15, f"{x} {y} {times} {times_py} {delta_times}" + + divide = x/y + divide_py = eval("x/y", py_dict) + delta_divide = abs(divide/divide_py - 1) + assert delta_divide < 1e-15, f"{x} {y} {divide} {divide_py} {delta_divide}" + + divide2 = y/x + divide2_py = eval("y/x", py_dict) + delta_divide2 = abs(divide2/divide2_py - 1) + assert delta_divide2 < 1e-15, f"{x} {y} {divide2} {divide2_py} {delta_divide2}" + + pow_ = x**y + pow_py = eval("x**y", py_dict) + delta_pow = abs(pow_/pow_py - 1) + assert delta_pow < 1e-15, f"{x} {y} {pow_} {pow_py} {delta_pow}" + + pow2 = y**x + pow2_py = eval("y**x", py_dict) + delta_pow2 = abs(pow2/pow2_py - 1) + assert delta_pow2 < 1e-15, f"{x} {y} {pow2} {pow2_py} {delta_pow2}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/tests/run/fused_types.pyx new/Cython-0.29.33/tests/run/fused_types.pyx --- old/Cython-0.29.32/tests/run/fused_types.pyx 2022-07-29 08:30:24.291704200 +0200 +++ new/Cython-0.29.33/tests/run/fused_types.pyx 2023-01-05 23:13:06.777018800 +0100 @@ -1,4 +1,5 @@ # mode: run +# ticket: 1772 cimport cython from cython.view cimport array @@ -363,6 +364,22 @@ """ print cython.typeof(array1), cython.typeof(array2), cython.typeof(array3) +def test_fused_const_memslice_dtype_repeated(const cython.floating[:] array1, cython.floating[:] array2): + """Test fused types memory view with one being const + + >>> sorted(test_fused_const_memslice_dtype_repeated.__signatures__) + ['double', 'float'] + + >>> test_fused_const_memslice_dtype_repeated(get_array(8, 'd'), get_array(8, 'd')) + const double[:] double[:] + >>> test_fused_const_memslice_dtype_repeated(get_array(4, 'f'), get_array(4, 'f')) + const float[:] float[:] + >>> test_fused_const_memslice_dtype_repeated(get_array(8, 'd'), get_array(4, 'f')) + Traceback (most recent call last): + ValueError: Buffer dtype mismatch, expected 'double' but got 'float' + """ + print cython.typeof(array1), cython.typeof(array2) + def test_cython_numeric(cython.numeric arg): """ Test to see whether complex numbers have their utility code declared @@ -388,6 +405,18 @@ """ _test_index_fused_args[cython.floating, ints_t](f, i) +cdef _test_index_const_fused_args(const cython.floating f, const ints_t i): + print(cython.typeof(f), cython.typeof(i)) + +def test_index_const_fused_args(const cython.floating f, const ints_t i): + """Test indexing function implementation with const fused type args + + >>> import cython + >>> test_index_const_fused_args[cython.double, cython.int](2.0, 3) + ('const double', 'const int') + """ + _test_index_const_fused_args[cython.floating, ints_t](f, i) + def test_composite(fused_composite x): """ @@ -404,6 +433,30 @@ return 2 * x +cdef cdef_func_const_fused_arg(const cython.floating val, + const fused_type1 * ptr_to_const, + const (cython.floating *) const_ptr): + print(val, cython.typeof(val)) + print(ptr_to_const[0], cython.typeof(ptr_to_const[0])) + print(const_ptr[0], cython.typeof(const_ptr[0])) + + ptr_to_const = NULL # pointer is not const, value is const + const_ptr[0] = 0.0 # pointer is const, value is not const + +def test_cdef_func_with_const_fused_arg(): + """Test cdef function with const fused type argument + + >>> test_cdef_func_with_const_fused_arg() + (0.0, 'const float') + (1, 'const int') + (2.0, 'float') + """ + cdef float arg0 = 0.0 + cdef int arg1 = 1 + cdef float arg2 = 2.0 + cdef_func_const_fused_arg(arg0, &arg1, &arg2) + + ### see GH3642 - presence of cdef inside "unrelated" caused a type to be incorrectly inferred cdef unrelated(cython.floating x): cdef cython.floating t = 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/tests/run/if_else_expr.pyx new/Cython-0.29.33/tests/run/if_else_expr.pyx --- old/Cython-0.29.32/tests/run/if_else_expr.pyx 2022-07-29 08:30:24.291704200 +0200 +++ new/Cython-0.29.33/tests/run/if_else_expr.pyx 2023-01-05 23:13:06.777018800 +0100 @@ -1,5 +1,6 @@ # mode: run # tag: condexpr +# ticket: 5197 cimport cython @@ -67,3 +68,48 @@ 3.0 """ return (math.floor if round_down else math.ceil)(x) + + +def performance_gh5197(patternsList): + """ + >>> performance_gh5197([]) # do not actually run anything, just see that things work at all + """ + # Coercing the types in nested conditional expressions used to slow down exponentially. + # See https://github.com/cython/cython/issues/5197 + import re + matched=[] + for _ in range(len(patternsList)): + try: + matched.append(patternsList[_].split('|')[-1].split('/')[-1] + 'pattr1' if re.search('^SomeString.*EndIng$')\ + else patternsList[_].split('|a')[-1].split('/a')[-1] + 'pattr2' if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|a')[-1].split('/a')[-1] + 'pattr2' if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + # else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + # else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + # else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + # else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + # else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + # else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + # else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] if re.search('^SomeOtherString.?Number.*EndIng$')\ + else patternsList[_].split('|b')[-1].split('/b')[-1] + 'pattr2' + patternsList[_].split('/')[-1].split('//')[-1] ) + except Exception as e: + matched.append('Error at Indx:%s-%s' %(_, patternsList[_])) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/tests/run/numpy_parallel.pyx new/Cython-0.29.33/tests/run/numpy_parallel.pyx --- old/Cython-0.29.32/tests/run/numpy_parallel.pyx 2022-07-29 08:30:24.295704100 +0200 +++ new/Cython-0.29.33/tests/run/numpy_parallel.pyx 2023-01-05 23:13:06.781018700 +0100 @@ -32,7 +32,7 @@ print i return - x = numpy.zeros(10, dtype=numpy.int) + x = numpy.zeros(10, dtype=numpy.int_) for i in prange(x.shape[0], nogil=True): x[i] = i - 5 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/tests/run/numpy_test.pyx new/Cython-0.29.33/tests/run/numpy_test.pyx --- old/Cython-0.29.32/tests/run/numpy_test.pyx 2022-07-29 08:30:24.295704100 +0200 +++ new/Cython-0.29.33/tests/run/numpy_test.pyx 2023-01-05 23:13:06.781018700 +0100 @@ -158,9 +158,9 @@ >>> test_dtype('D', inc1_cdouble_struct) >>> test_dtype('G', inc1_clongdouble_struct) - >>> test_dtype(np.int, inc1_int_t) + >>> test_dtype(np.int_, inc1_int_t) >>> test_dtype(np.longlong, inc1_longlong_t) - >>> test_dtype(np.float, inc1_float_t) + >>> test_dtype(np.float_, inc1_float_t) >>> test_dtype(np.double, inc1_double_t) >>> test_dtype(np.intp, inc1_intp_t) >>> test_dtype(np.uintp, inc1_uintp_t) @@ -657,7 +657,7 @@ ndarray[float complex,ndim=1] ndarray[float complex,ndim=1] (5+0j) (6+0j) >>> test_fused_ndarray_other_dtypes(np.arange(10, dtype=np.complex128)) ndarray[double complex,ndim=1] ndarray[double complex,ndim=1] (5+0j) (6+0j) - >>> test_fused_ndarray_other_dtypes(np.arange(10, dtype=np.object)) + >>> test_fused_ndarray_other_dtypes(np.arange(10, dtype=np.object_)) ndarray[Python object,ndim=1] ndarray[Python object,ndim=1] 5 6 """ cdef np.ndarray[fused_dtype, ndim=1] b = a @@ -802,7 +802,7 @@ def test_dispatch_external_typedef(np.ndarray[confusing_fused_typedef] a): """ - >>> test_dispatch_external_typedef(np.arange(-5, 5, dtype=np.long)) + >>> test_dispatch_external_typedef(np.arange(-5, 5, dtype=np.int_)) -2 """ print a[3] @@ -831,7 +831,7 @@ float[:] float[:] 5.0 6.0 >>> test_fused_memslice_other_dtypes(np.arange(10, dtype=np.dtype('i'))) int[:] int[:] 5 6 - >>> test_fused_memslice_other_dtypes(np.arange(10, dtype=np.object)) + >>> test_fused_memslice_other_dtypes(np.arange(10, dtype=np.object_)) object[:] object[:] 5 6 """ cdef memslice_fused_dtype[:] b = a @@ -860,7 +860,7 @@ float[:] float[:] 5.0 6.0 >>> test_fused_memslice(np.arange(10, dtype=np.dtype('i'))) int[:] int[:] 5 6 - >>> test_fused_memslice(np.arange(10, dtype=np.object)) + >>> test_fused_memslice(np.arange(10, dtype=np.object_)) object[:] object[:] 5 6 """ cdef memslice_fused b = a diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/tests/run/py35_asyncio_async_def.srctree new/Cython-0.29.33/tests/run/py35_asyncio_async_def.srctree --- old/Cython-0.29.32/tests/run/py35_asyncio_async_def.srctree 2022-07-29 08:30:24.299704000 +0200 +++ new/Cython-0.29.33/tests/run/py35_asyncio_async_def.srctree 2023-01-05 23:13:06.785018700 +0100 @@ -24,7 +24,7 @@ async def main(): await cy_test.say() -with closing(asyncio.get_event_loop()) as loop: +with closing(asyncio.new_event_loop()) as loop: print("Running Python coroutine ...") loop.run_until_complete(main()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Cython-0.29.32/tox.ini new/Cython-0.29.33/tox.ini --- old/Cython-0.29.32/tox.ini 1970-01-01 01:00:00.000000000 +0100 +++ new/Cython-0.29.33/tox.ini 2023-01-05 23:13:06.793018800 +0100 @@ -0,0 +1,18 @@ +# Tox (http://tox.testrun.org/) is a tool for running tests +# in multiple virtualenvs. This configuration file will run the +# test suite on all supported python versions. To use it, "pip install tox" +# and then run "tox" from this directory. + +[tox] +envlist = py26, py27, py34, py35, py36, py37, py38, py39, py310, py311, pypy + +[testenv] +setenv = CFLAGS=-O0 -ggdb +commands = + {envpython} runtests.py -vv + +[pycodestyle] +ignore = W, E +select = E711, E714, E501, W291 +max-line-length = 150 +format = pylint