From 571e3b0862e4a5fb9ea2289eea934dcead6f109b Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 27 Nov 2008 08:44:00 +0100 Subject: [PATCH] fix iterdict transform for new temp semantics --- Cython/Compiler/Optimize.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index 6b1f64c9..3a3d7dcc 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -76,7 +76,7 @@ class DictIterTransform(Visitor.VisitorTransform): dict_temp = temp.ref(dict_obj.pos) temp = UtilNodes.TempHandle(PyrexTypes.c_py_ssize_t_type) temps.append(temp) - pos_temp = temp.ref(dict_obj.pos) + pos_temp = temp.ref(node.pos) pos_temp_addr = ExprNodes.AmpersandNode( node.pos, operand=pos_temp, type=PyrexTypes.c_ptr_type(PyrexTypes.c_py_ssize_t_type)) @@ -142,8 +142,8 @@ class DictIterTransform(Visitor.VisitorTransform): stats = [node.body]) if tuple_target: - temp = UtilNodes.TempHandle(PyrexTypes.py_object_type) - temps.append(temp) + temp = UtilNodes.TempHandle(Builtin.tuple_type) + temp.needs_cleanup = False # assignment steals the reference temp_tuple = temp.ref(tuple_target.pos) class TempTupleNode(ExprNodes.TupleNode): # FIXME: remove this after result-code refactoring @@ -156,10 +156,13 @@ class DictIterTransform(Visitor.VisitorTransform): is_temp = 1, type = Builtin.tuple_type, ) - body.stats.insert(0, Nodes.SingleAssignmentNode( - pos = tuple_target.pos, - lhs = tuple_target, - rhs = tuple_result)) + body.stats.insert( + 0, UtilNodes.TempsBlockNode( + tuple_target.pos, temps = [temp], + body = Nodes.SingleAssignmentNode( + pos = tuple_target.pos, + lhs = tuple_target, + rhs = tuple_result))) else: # execute all coercions before the assignments coercion_stats = [] @@ -216,7 +219,7 @@ class DictIterTransform(Visitor.VisitorTransform): return UtilNodes.TempsBlockNode( node.pos, temps=temps, body=Nodes.StatListNode( - pos = node.pos, + node.pos, stats = result_code )) -- 2.26.2