From 091f3d0845a9dd359536383c207509c42c361e1d Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sat, 11 Dec 2010 01:03:45 +0100 Subject: [PATCH] store away temp values *after* calculating the yield result value --- Cython/Compiler/ExprNodes.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 1c3939f7..1fb7e780 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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) -- 2.26.2