fix local variable init code in ScopedExprNode
authorStefan Behnel <scoder@users.berlios.de>
Thu, 9 Dec 2010 15:57:07 +0000 (16:57 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Thu, 9 Dec 2010 15:57:07 +0000 (16:57 +0100)
Cython/Compiler/ExprNodes.py

index d58e9823e7c01cc17970a5a1332e388625ef17b8..0e89b311ff04d5b142c0eb165c81e978aa8f0218 100755 (executable)
@@ -4181,12 +4181,13 @@ class ScopedExprNode(ExprNode):
                 code.put_var_declaration(entry)
                 if entry.type.is_pyobject and entry.used:
                     py_entries.append(entry)
-                    code.put_init_var_to_py_none(entry)
         if not py_entries:
             # no local Python references => no cleanup required
             generate_inner_evaluation_code(code)
             code.putln('} /* exit inner scope */')
             return
+        for entry in py_entries:
+            code.put_init_var_to_py_none(entry)
 
         # must free all local Python references at each exit point
         old_loop_labels = tuple(code.new_loop_labels())