From: Stefan Behnel Date: Wed, 26 Nov 2008 13:02:35 +0000 (+0100) Subject: fix for two problems with optimised dict iteration, including work-around for ticket... X-Git-Tag: 0.11-beta~212 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=05d3d0e8625ad629760009af1a07d473aab3776b;p=cython.git fix for two problems with optimised dict iteration, including work-around for ticket #123 --- diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index 40f7b5e8..6b1f64c9 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -74,7 +74,9 @@ class DictIterTransform(Visitor.VisitorTransform): temp = UtilNodes.TempHandle(PyrexTypes.py_object_type) temps.append(temp) dict_temp = temp.ref(dict_obj.pos) - pos_temp = node.iterator.counter + temp = UtilNodes.TempHandle(PyrexTypes.c_py_ssize_t_type) + temps.append(temp) + pos_temp = temp.ref(dict_obj.pos) pos_temp_addr = ExprNodes.AmpersandNode( node.pos, operand=pos_temp, type=PyrexTypes.c_ptr_type(PyrexTypes.c_py_ssize_t_type)) @@ -115,14 +117,13 @@ class DictIterTransform(Visitor.VisitorTransform): class FakeEnv(object): nogil = False if dest_type.is_pyobject: - coercion = None if dest_type.is_extension_type or dest_type.is_builtin_type: - coercion = ExprNodes.PyTypeTestNode(obj_node, dest_type, FakeEnv()) + obj_node = ExprNodes.PyTypeTestNode(obj_node, dest_type, FakeEnv()) result = ExprNodes.TypecastNode( obj_node.pos, operand = obj_node, type = dest_type) - return (result, coercion) + return (result, None) else: temp = UtilNodes.TempHandle(dest_type) temps.append(temp)