diff options
author | shadchin <[email protected]> | 2025-05-23 07:16:06 +0300 |
---|---|---|
committer | shadchin <[email protected]> | 2025-05-23 07:32:45 +0300 |
commit | 1bea05b3f8c2d30248dda30232aee5ce41485141 (patch) | |
tree | dd29d6ab31ce190712cf21a1a07d7b7053dc7204 | |
parent | bb919ff615bff1f8a16a321843cd843497ae83d1 (diff) |
Update Cython to 3.0.12
commit_hash:96359824bab02082b58bc1c40c68f9462e3ffc3a
21 files changed, 118 insertions, 72 deletions
diff --git a/build/ymake.core.conf b/build/ymake.core.conf index 1c4d6ce2047..ea44d97c99e 100644 --- a/build/ymake.core.conf +++ b/build/ymake.core.conf @@ -13,7 +13,7 @@ CPP_FAKEID=2024-01-23 GO_FAKEID=11100371 ANDROID_FAKEID=2023-05-17 CLANG_TIDY_FAKEID=2023-06-06 -CYTHON_FAKEID=16586418 +CYTHON_FAKEID=16618405 JAVA_FAKEID=14386852 PROTO_FAKEID=0 FBS_FAKEID=2024-03-13 diff --git a/contrib/tools/cython/.dist-info/METADATA b/contrib/tools/cython/.dist-info/METADATA index 197a6e14edc..6364708211f 100644 --- a/contrib/tools/cython/.dist-info/METADATA +++ b/contrib/tools/cython/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: Cython -Version: 3.0.11 +Version: 3.0.12 Summary: The Cython compiler for writing C extensions in the Python language. Home-page: https://cython.org/ Author: Robert Bradshaw, Stefan Behnel, Dag Seljebotn, Greg Ewing, et al. @@ -28,9 +28,12 @@ Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 +Classifier: Programming Language :: Python :: 3.13 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy +Classifier: Programming Language :: Python :: Implementation :: Stackless Classifier: Programming Language :: C +Classifier: Programming Language :: C++ Classifier: Programming Language :: Cython Classifier: Topic :: Software Development :: Code Generators Classifier: Topic :: Software Development :: Compilers diff --git a/contrib/tools/cython/.yandex_meta/override.nix b/contrib/tools/cython/.yandex_meta/override.nix index 68cfcf5e2ba..bdcb08cfc03 100644 --- a/contrib/tools/cython/.yandex_meta/override.nix +++ b/contrib/tools/cython/.yandex_meta/override.nix @@ -1,10 +1,10 @@ pkgs: attrs: with pkgs; with pkgs.python311.pkgs; with attrs; rec { - version = "3.0.11"; + version = "3.0.12"; src = fetchPypi { pname = "cython"; inherit version; - hash = "sha256-cUbdKvhoK0ymEzGFHmrrzp/lFY51MAND+AwHyoCx+v8="; + hash = "sha256-uYi7KXznbGceKMl9AXuVQRAQ98d/pmI90LtH7tGu4bw="; }; patches = []; diff --git a/contrib/tools/cython/CHANGES.rst b/contrib/tools/cython/CHANGES.rst index 895bc335486..6d1ccad7e6d 100644 --- a/contrib/tools/cython/CHANGES.rst +++ b/contrib/tools/cython/CHANGES.rst @@ -2,6 +2,35 @@ Cython Changelog ================ +3.0.12 (2025-02-11) +=================== + +Bugs fixed +---------- + +* Release 3.0.11 introduced some incorrect ``noexcept`` warnings. + (Github issue :issue:`6335`) + +* Conditional assignments to variables using the walrus operator could crash. + (Github issue :issue:`6094`) + +* Dict assignments to struct members with reserved C names could generate invalid C code. + +* Fused ctuples with the same entry types but different sizes could fail to compile. + (Github issue :issue:`6328`) + +* In Py3, `pyximport` was not searching `sys.path` when looking for importable source files. + (Github issue :issue:`5615`) + +* Using `& 0` on integers produced with `int.from_bytes()` could read invalid memory on Python 3.10. + (Github issue :issue:`6480`) + +* Modules could fail to compile in PyPy 3.11 due to missing CPython specific header files. + Patch by Matti Picus. (Github issue :issue:`6482`) + +* Minor fix in C++ ``partial_sum()`` declaration. + + 3.0.11 (2024-08-05) =================== diff --git a/contrib/tools/cython/Cython/Compiler/Code.py b/contrib/tools/cython/Cython/Compiler/Code.py index cd7ca03443d..395dbbd5ff8 100644 --- a/contrib/tools/cython/Cython/Compiler/Code.py +++ b/contrib/tools/cython/Cython/Compiler/Code.py @@ -140,7 +140,7 @@ class IncludeCode(object): # order int: sorting order (automatically set by increasing counter) # Constants for location. If the same include occurs with different - # locations, the earliest one takes precedense. + # locations, the earliest one takes precedence. INITIAL = 0 EARLY = 1 LATE = 2 diff --git a/contrib/tools/cython/Cython/Compiler/ExprNodes.py b/contrib/tools/cython/Cython/Compiler/ExprNodes.py index 952617e375d..756c5f90ad5 100644 --- a/contrib/tools/cython/Cython/Compiler/ExprNodes.py +++ b/contrib/tools/cython/Cython/Compiler/ExprNodes.py @@ -1052,7 +1052,7 @@ class ExprNode(Node): src = CoerceToPyTypeNode(src, env, type=dst_type) # FIXME: I would expect that CoerceToPyTypeNode(type=dst_type) returns a value of type dst_type # but it doesn't for ctuples. Thus, we add a PyTypeTestNode which then triggers the - # Python conversion and becomes useless. That sems backwards and inefficient. + # Python conversion and becomes useless. That seems backwards and inefficient. # We should not need a PyTypeTestNode after a previous conversion above. if not src.type.subtype_of(dst_type): src = PyTypeTestNode(src, dst_type, env) @@ -9296,6 +9296,9 @@ class DictNode(ExprNode): len(self.key_value_pairs), code.error_goto_if_null(self.result(), self.pos))) self.generate_gotref(code) + struct_scope = None + else: + struct_scope = self.type.scope keys_seen = set() key_type = None @@ -9344,17 +9347,16 @@ class DictNode(ExprNode): if self.exclude_null_values: code.putln('}') else: + key = str(item.key.value) + member = struct_scope.lookup_here(key) + assert member is not None, "struct member %s not found, error was not handled during coercion" % key + key_cname = member.cname + value_cname = item.value.result() if item.value.type.is_array: code.putln("memcpy(%s.%s, %s, sizeof(%s));" % ( - self.result(), - item.key.value, - item.value.result(), - item.value.result())) + self.result(), key_cname, value_cname, value_cname)) else: - code.putln("%s.%s = %s;" % ( - self.result(), - item.key.value, - item.value.result())) + code.putln("%s.%s = %s;" % (self.result(), key_cname, value_cname)) item.generate_disposal_code(code) item.free_temps(code) diff --git a/contrib/tools/cython/Cython/Compiler/FlowControl.py b/contrib/tools/cython/Cython/Compiler/FlowControl.py index c8575435738..a9965b76c69 100644 --- a/contrib/tools/cython/Cython/Compiler/FlowControl.py +++ b/contrib/tools/cython/Cython/Compiler/FlowControl.py @@ -1381,3 +1381,45 @@ class ControlFlowAnalysis(CythonTransform): self.mark_assignment(node.operand, fake_rhs_expr) self.visitchildren(node) return node + + def visit_BoolBinopNode(self, node): + # Note - I don't believe BoolBinopResultNode needs special handling beyond this + assert len(node.subexprs) == 2 # operand1 and operand2 only + + next_block = self.flow.newblock() + parent = self.flow.block + + self._visit(node.operand1) + + self.flow.nextblock() + self._visit(node.operand2) + if self.flow.block: + self.flow.block.add_child(next_block) + + parent.add_child(next_block) + + if next_block.parents: + self.flow.block = next_block + else: + self.flow.block = None + return node + + def visit_CondExprNode(self, node): + assert len(node.subexprs) == 3 + self._visit(node.test) + parent = self.flow.block + next_block = self.flow.newblock() + self.flow.nextblock() + self._visit(node.true_val) + if self.flow.block: + self.flow.block.add_child(next_block) + self.flow.nextblock(parent=parent) + self._visit(node.false_val) + if self.flow.block: + self.flow.block.add_child(next_block) + + if next_block.parents: + self.flow.block = next_block + else: + self.flow.block = None + return node diff --git a/contrib/tools/cython/Cython/Compiler/Nodes.py b/contrib/tools/cython/Cython/Compiler/Nodes.py index e1fe6ee56c9..dde377c323a 100644 --- a/contrib/tools/cython/Cython/Compiler/Nodes.py +++ b/contrib/tools/cython/Cython/Compiler/Nodes.py @@ -3126,7 +3126,11 @@ class DefNode(FuncDefNode): if scope is None: scope = cfunc.scope cfunc_type = cfunc.type - has_explicit_exc_clause=True + if cfunc_type.exception_check: + # this ensures `legacy_implicit_noexcept` does not trigger + # as it would result in a mismatch + # (declaration with except, definition with implicit noexcept) + has_explicit_exc_clause = True if len(self.args) != len(cfunc_type.args) or cfunc_type.has_varargs: error(self.pos, "wrong number of arguments") error(cfunc.pos, "previous declaration here") diff --git a/contrib/tools/cython/Cython/Compiler/PyrexTypes.py b/contrib/tools/cython/Cython/Compiler/PyrexTypes.py index b522a131751..1080b2ef039 100644 --- a/contrib/tools/cython/Cython/Compiler/PyrexTypes.py +++ b/contrib/tools/cython/Cython/Compiler/PyrexTypes.py @@ -4678,7 +4678,8 @@ class CTupleType(CType): def c_tuple_type(components): components = tuple(components) if any(c.is_fused for c in components): - cname = "<dummy fused ctuple>" # should never end up in code + # should never end up in code but should be unique + cname = "<dummy fused ctuple %s>" % repr(components) else: cname = Naming.ctuple_type_prefix + type_list_identifier(components) tuple_type = CTupleType(cname, components) diff --git a/contrib/tools/cython/Cython/Compiler/Visitor.py b/contrib/tools/cython/Cython/Compiler/Visitor.py index 92e2eb9c0d3..105347b36d5 100644 --- a/contrib/tools/cython/Cython/Compiler/Visitor.py +++ b/contrib/tools/cython/Cython/Compiler/Visitor.py @@ -847,7 +847,8 @@ class PrintTree(TreeVisitor): elif isinstance(node, Nodes.DefNode): result += "(name=\"%s\")" % node.name elif isinstance(node, Nodes.CFuncDefNode): - result += "(name=\"%s\")" % node.declared_name() + result += "(name=\"%s\", type=\"%s\")" % ( + node.declared_name(), getattr(node, "type", None)) elif isinstance(node, ExprNodes.AttributeNode): result += "(type=%s, attribute=\"%s\")" % (repr(node.type), node.attribute) elif isinstance(node, (ExprNodes.ConstNode, ExprNodes.PyConstNode)): diff --git a/contrib/tools/cython/Cython/Includes/libcpp/numeric.pxd b/contrib/tools/cython/Cython/Includes/libcpp/numeric.pxd index a9fb37205a5..99175f82cfc 100644 --- a/contrib/tools/cython/Cython/Includes/libcpp/numeric.pxd +++ b/contrib/tools/cython/Cython/Includes/libcpp/numeric.pxd @@ -17,7 +17,7 @@ cdef extern from "<numeric>" namespace "std" nogil: void adjacent_difference[InputIt, OutputIt, BinaryOperation](InputIt in_first, InputIt in_last, OutputIt out_first, BinaryOperation op) - void partial_sum[InputIt, OutputIt](InputIt in_first, OutputIt in_last, OutputIt out_first) + void partial_sum[InputIt, OutputIt](InputIt in_first, InputIt in_last, OutputIt out_first) void partial_sum[InputIt, OutputIt, BinaryOperation](InputIt in_first, InputIt in_last, OutputIt out_first, BinaryOperation op) diff --git a/contrib/tools/cython/Cython/Shadow.py b/contrib/tools/cython/Cython/Shadow.py index 1400f1657c8..1b0953614ad 100644 --- a/contrib/tools/cython/Cython/Shadow.py +++ b/contrib/tools/cython/Cython/Shadow.py @@ -2,7 +2,7 @@ from __future__ import absolute_import # Possible version formats: "3.1.0", "3.1.0a1", "3.1.0a1.dev0" -__version__ = "3.0.11" +__version__ = "3.0.12" try: from __builtin__ import basestring diff --git a/contrib/tools/cython/Cython/Utility/Coroutine.c b/contrib/tools/cython/Cython/Utility/Coroutine.c index c7ec8ee9ba0..1aecf1d5e6b 100644 --- a/contrib/tools/cython/Cython/Utility/Coroutine.c +++ b/contrib/tools/cython/Cython/Utility/Coroutine.c @@ -501,7 +501,7 @@ static int __pyx_Generator_init(PyObject *module); /*proto*/ //@requires: ModuleSetupCode.c::IncludeStructmemberH #include <frameobject.h> -#if PY_VERSION_HEX >= 0x030b00a6 +#if PY_VERSION_HEX >= 0x030b00a6 && !defined(PYPY_VERSION) #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif diff --git a/contrib/tools/cython/Cython/Utility/Exceptions.c b/contrib/tools/cython/Cython/Utility/Exceptions.c index 46f7dd57812..ab6f69fb182 100644 --- a/contrib/tools/cython/Cython/Utility/Exceptions.c +++ b/contrib/tools/cython/Cython/Utility/Exceptions.c @@ -914,7 +914,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, #include "compile.h" #include "frameobject.h" #include "traceback.h" -#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API +#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION) #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif diff --git a/contrib/tools/cython/Cython/Utility/ObjectHandling.c b/contrib/tools/cython/Cython/Utility/ObjectHandling.c index b0a8554a7c5..8147a907457 100644 --- a/contrib/tools/cython/Cython/Utility/ObjectHandling.c +++ b/contrib/tools/cython/Cython/Utility/ObjectHandling.c @@ -2530,7 +2530,7 @@ static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, #if !CYTHON_VECTORCALL #if PY_VERSION_HEX >= 0x03080000 #include "frameobject.h" -#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API +#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION) #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif diff --git a/contrib/tools/cython/Cython/Utility/Optimize.c b/contrib/tools/cython/Cython/Utility/Optimize.c index 99e9a8db375..daa936dc83a 100644 --- a/contrib/tools/cython/Cython/Utility/Optimize.c +++ b/contrib/tools/cython/Cython/Utility/Optimize.c @@ -1281,15 +1281,6 @@ static {{c_ret_type}} {{cfunc_name}}(PyObject *op1, PyObject *op2, long intval, PY_LONG_LONG ll{{ival}}, llx; #endif {{endif}} - {{if c_op == '&'}} - // special case for &-ing arbitrarily large numbers with known single digit operands - if ((intval & PyLong_MASK) == intval) { - // Calling PyLong_CompactValue() requires the PyLong value to be compact, we only need the last digit. - long last_digit = (long) __Pyx_PyLong_Digits({{pyval}})[0]; - long result = intval & (likely(__Pyx_PyLong_IsPos({{pyval}})) ? last_digit : (PyLong_MASK - last_digit + 1)); - return PyLong_FromLong(result); - } - {{endif}} // special cases for 0: + - * % / // | ^ & >> << if (unlikely(__Pyx_PyLong_IsZero({{pyval}}))) { {{if order == 'CObj' and c_op in '%/'}} @@ -1312,6 +1303,15 @@ static {{c_ret_type}} {{cfunc_name}}(PyObject *op1, PyObject *op2, long intval, return __Pyx_NewRef(op1); {{endif}} } + {{if c_op == '&'}} + // special case for &-ing arbitrarily large numbers with known single digit operands + if ((intval & PyLong_MASK) == intval) { + // Calling PyLong_CompactValue() requires the PyLong value to be compact, we only need the last digit. + long last_digit = (long) __Pyx_PyLong_Digits({{pyval}})[0]; + long result = intval & (likely(__Pyx_PyLong_IsPos({{pyval}})) ? last_digit : (PyLong_MASK - last_digit + 1)); + return PyLong_FromLong(result); + } + {{endif}} // handle most common case first to avoid indirect branch and optimise branch prediction if (likely(__Pyx_PyLong_IsCompact({{pyval}}))) { {{ival}} = __Pyx_PyLong_CompactValue({{pyval}}); diff --git a/contrib/tools/cython/Cython/Utility/Overflow.c b/contrib/tools/cython/Cython/Utility/Overflow.c index 395456c8721..0ae375d78c3 100644 --- a/contrib/tools/cython/Cython/Utility/Overflow.c +++ b/contrib/tools/cython/Cython/Utility/Overflow.c @@ -1,7 +1,7 @@ /* These functions provide integer arithmetic with integer checking. They do not actually raise an exception when an overflow is detected, but rather set a bit -in the overflow parameter. (This parameter may be re-used across several +in the overflow parameter. (This parameter may be reused across several arithmetic operations, so should be or-ed rather than assigned to.) The implementation is divided into two parts, the signed and unsigned basecases, diff --git a/contrib/tools/cython/Cython/Utility/Profile.c b/contrib/tools/cython/Cython/Utility/Profile.c index 2b8564b226f..3b4d8514949 100644 --- a/contrib/tools/cython/Cython/Utility/Profile.c +++ b/contrib/tools/cython/Cython/Utility/Profile.c @@ -38,7 +38,7 @@ #include "compile.h" #include "frameobject.h" #include "traceback.h" -#if PY_VERSION_HEX >= 0x030b00a6 +#if PY_VERSION_HEX >= 0x030b00a6 && !defined(PYPY_VERSION) #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif diff --git a/contrib/tools/cython/cython.py b/contrib/tools/cython/cython.py index d8ab80706b9..951184229b0 100755 --- a/contrib/tools/cython/cython.py +++ b/contrib/tools/cython/cython.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Change content of this file to change uids for cython programs - cython 3.0.11 r0 +# Change content of this file to change uids for cython programs - cython 3.0.12 r0 # # Cython -- Main Program, generic diff --git a/contrib/tools/cython/patches/pr6343.patch b/contrib/tools/cython/patches/pr6343.patch deleted file mode 100644 index faffef9e0b8..00000000000 --- a/contrib/tools/cython/patches/pr6343.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 2e774fca5ad55371b21ba2b531d218888319c151 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <[email protected]> -Date: Sun, 18 Aug 2024 17:43:05 -0300 -Subject: [PATCH 1/2] Better fix for #6122 to avoid #6535 - -The change in #6124 introduces a regression with functions that are -implicit noexcept in a pxd file. ---- - Cython/Compiler/Nodes.py | 5 ++--- - 1 file changed, 2 insertions(+), 3 deletions(-) - -diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py -index d4737f7c373..b70d766ed4e 100644 ---- a/Cython/Compiler/Nodes.py -+++ b/Cython/Compiler/Nodes.py -@@ -710,10 +710,8 @@ def analyse(self, return_type, env, nonempty=0, directive_locals=None, visibilit - and not self.has_explicit_exc_clause - and self.exception_check - and visibility != 'extern'): -- # If function is already declared from pxd, the exception_check has already correct value. -- if not (self.declared_name() in env.entries and not in_pxd): -- self.exception_check = False - # implicit noexcept, with a warning -+ self.exception_check = False - warning(self.pos, - "Implicit noexcept declaration is deprecated." - " Function declaration should contain 'noexcept' keyword.", -@@ -3128,6 +3126,7 @@ def as_cfunction(self, cfunc=None, scope=None, overridable=True, returns=None, e - if scope is None: - scope = cfunc.scope - cfunc_type = cfunc.type -+ has_explicit_exc_clause=True - if len(self.args) != len(cfunc_type.args) or cfunc_type.has_varargs: - error(self.pos, "wrong number of arguments") - error(cfunc.pos, "previous declaration here") - diff --git a/contrib/tools/cython/ya.make b/contrib/tools/cython/ya.make index 38619e6d9b4..86802cf6b30 100644 --- a/contrib/tools/cython/ya.make +++ b/contrib/tools/cython/ya.make @@ -11,9 +11,9 @@ LICENSE_TEXTS(.yandex_meta/licenses.list.txt) SUBSCRIBER(g:python-contrib) -VERSION(3.0.11) +VERSION(3.0.12) -ORIGINAL_SOURCE(mirror://pypi/c/cython/cython-3.0.11.tar.gz) +ORIGINAL_SOURCE(mirror://pypi/c/cython/cython-3.0.12.tar.gz) NO_LINT() |