Fix py target for-from loop.
authorRobert Bradshaw <robertwb@math.washington.edu>
Wed, 25 Mar 2009 20:05:22 +0000 (13:05 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Wed, 25 Mar 2009 20:05:22 +0000 (13:05 -0700)
--HG--
extra : transplant_source : %03%EF%05%8Dq3%FB%88%89G%2B%BC%7B%A5%A57%3A%C6%0Bs

Cython/Compiler/Nodes.py

index ec3d3317f42a08b2bd9cc8f7a6a74d8b4c9c9c1f..2035f070bee6274c0d4bd8a6bc29bb6b5582ecd1 100644 (file)
@@ -3999,8 +3999,16 @@ class ForFromStatNode(LoopNode, StatNode):
         if self.py_loopvar_node:
             # Reassign py variable to loop var here.
             # (For consistancy, should rarely come up in practice.)
-            pass
+            import ExprNodes
+            from_py_node = ExprNodes.CoerceFromPyTypeNode(self.loopvar_node.type, self.target, None)
+            from_py_node.temp_code = loopvar_name
+            from_py_node.generate_result_code(code)
         code.putln("}")
+        if self.py_loopvar_node:
+            # This is potentially wasteful, but we don't want the semantics to 
+            # depend on whether or not the loop is a python type. 
+            self.py_loopvar_node.generate_evaluation_code(code)
+            self.target.generate_assignment_code(self.py_loopvar_node, code)
         break_label = code.break_label
         code.set_loop_labels(old_loop_labels)
         if self.else_clause: