store away temp values *after* calculating the yield result value
authorStefan Behnel <scoder@users.berlios.de>
Sat, 11 Dec 2010 00:03:45 +0000 (01:03 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Sat, 11 Dec 2010 00:03:45 +0000 (01:03 +0100)
Cython/Compiler/ExprNodes.py

index 1c3939f7ee337898124b616bd40c6d47ccf2c33f..1fb7e780bf28a2f9fd91b520e294c9c45f752461 100755 (executable)
@@ -4983,13 +4983,6 @@ class YieldExprNode(ExprNode):
         env.use_utility_code(generator_utility_code)
 
     def generate_evaluation_code(self, code):
-        saved = []
-        self.temp_allocator.reset()
-        code.putln('/* Save temporary variables */')
-        for cname, type, manage_ref in code.funcstate.temps_in_use():
-            save_cname = self.temp_allocator.allocate_temp(type)
-            saved.append((cname, save_cname, type))
-            code.putln('%s->%s = %s;' % (Naming.cur_scope_cname, save_cname, cname))
         self.label_name = code.new_label('resume_from_yield')
         code.use_label(self.label_name)
         self.allocate_temp_result(code)
@@ -5005,6 +4998,13 @@ class YieldExprNode(ExprNode):
             self.arg.free_temps(code)
         else:
             code.put_init_to_py_none(Naming.retval_cname, py_object_type)
+        saved = []
+        self.temp_allocator.reset()
+        code.putln('/* Save temporary variables */')
+        for cname, type, manage_ref in code.funcstate.temps_in_use():
+            save_cname = self.temp_allocator.allocate_temp(type)
+            saved.append((cname, save_cname, type))
+            code.putln('%s->%s = %s;' % (Naming.cur_scope_cname, save_cname, cname))
 
         # XXX: safe here as all used temps are handled but not clean
         self.temp_allocator.put_giveref(code)