From edda878b29b9655770ec63054a73245ee3f1f15b Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Mon, 15 Nov 2010 10:31:21 +0100 Subject: [PATCH] cleanup --- Cython/Compiler/ExprNodes.py | 5 +---- Cython/Compiler/ParseTreeTransforms.py | 18 +++++++----------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 5f463f9b..20b8c4d6 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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: diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py index ae5bb142..42e9dd5c 100644 --- a/Cython/Compiler/ParseTreeTransforms.py +++ b/Cython/Compiler/ParseTreeTransforms.py @@ -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): -- 2.26.2