cleanup
authorStefan Behnel <scoder@users.berlios.de>
Mon, 15 Nov 2010 09:31:21 +0000 (10:31 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Mon, 15 Nov 2010 09:31:21 +0000 (10:31 +0100)
Cython/Compiler/ExprNodes.py
Cython/Compiler/ParseTreeTransforms.py

index 5f463f9bf11bbdb1d329d8b11fe246f05aa169a9..20b8c4d63acbbbebf1a86012a5a7c4c836eab921 100755 (executable)
@@ -4141,10 +4141,7 @@ class ComprehensionNode(ScopedExprNode):
     def analyse_declarations(self, env):
         self.append.target = self # this is used in the PyList_Append of the inner loop
         self.init_scope(env)
-        if self.expr_scope is not None:
-            self.loop.analyse_declarations(self.expr_scope)
-        else:
-            self.loop.analyse_declarations(env)
+        self.loop.analyse_declarations(self.expr_scope or env)
 
     def init_scope(self, outer_scope, expr_scope=None):
         if expr_scope is not None:
index ae5bb142a9ef4b409f442aa5c69e6440fb72bc0e..42e9dd5ce95e654497b070bad76900d02f51ea22 100644 (file)
@@ -1057,21 +1057,17 @@ property NAME:
         self.seen_vars_stack.pop()
         return node
 
-    def visit_ComprehensionNode(self, node):
-        self.visitchildren(node)
-        node.analyse_declarations(self.env_stack[-1])
-        return node
-
     def visit_ScopedExprNode(self, node):
         node.analyse_declarations(self.env_stack[-1])
-        if self.seen_vars_stack:
+        # the node may or may not have a local scope
+        if node.expr_scope:
             self.seen_vars_stack.append(set(self.seen_vars_stack[-1]))
+            self.env_stack.append(node.expr_scope)
+            self.visitchildren(node)
+            self.env_stack.pop()
+            self.seen_vars_stack.pop()
         else:
-            self.seen_vars_stack.append(set())
-        self.env_stack.append(node.expr_scope)
-        self.visitchildren(node)
-        self.env_stack.pop()
-        self.seen_vars_stack.pop()
+            self.visitchildren(node)
         return node
 
     def visit_TempResultFromStatNode(self, node):