summaryrefslogtreecommitdiffstats
path: root/contrib/tools/cython/Cython/Compiler
diff options
context:
space:
mode:
authorshadchin <[email protected]>2025-05-23 07:16:06 +0300
committershadchin <[email protected]>2025-05-23 07:32:45 +0300
commit1bea05b3f8c2d30248dda30232aee5ce41485141 (patch)
treedd29d6ab31ce190712cf21a1a07d7b7053dc7204 /contrib/tools/cython/Cython/Compiler
parentbb919ff615bff1f8a16a321843cd843497ae83d1 (diff)
Update Cython to 3.0.12
commit_hash:96359824bab02082b58bc1c40c68f9462e3ffc3a
Diffstat (limited to 'contrib/tools/cython/Cython/Compiler')
-rw-r--r--contrib/tools/cython/Cython/Compiler/Code.py2
-rw-r--r--contrib/tools/cython/Cython/Compiler/ExprNodes.py20
-rw-r--r--contrib/tools/cython/Cython/Compiler/FlowControl.py42
-rw-r--r--contrib/tools/cython/Cython/Compiler/Nodes.py6
-rw-r--r--contrib/tools/cython/Cython/Compiler/PyrexTypes.py3
-rw-r--r--contrib/tools/cython/Cython/Compiler/Visitor.py3
6 files changed, 63 insertions, 13 deletions
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)):