From 699d2353146ca122c298de8e545e11335d751d12 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Sat, 21 Nov 2009 16:28:04 -0800 Subject: [PATCH] Fix bug in handling of environment directives. --- Cython/Compiler/Nodes.py | 2 ++ Cython/Compiler/ParseTreeTransforms.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 8ee5b6c6..1f9f3aba 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -1379,6 +1379,7 @@ class CFuncDefNode(FuncDefNode): if not env.is_module_scope or Options.lookup_module_cpdef: self.override = OverrideCheckNode(self.pos, py_func = self.py_func) self.body = StatListNode(self.pos, stats=[self.override, self.body]) + self.create_local_scope(env) def call_self_node(self, omit_optional_args=0, is_module_scope=0): import ExprNodes @@ -1706,6 +1707,7 @@ class DefNode(FuncDefNode): self.declare_pyfunction(env) self.analyse_signature(env) self.return_type = self.entry.signature.return_type() + self.create_local_scope(env) def analyse_signature(self, env): any_type_tests_needed = 0 diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py index 7c6c546b..c65a30b5 100644 --- a/Cython/Compiler/ParseTreeTransforms.py +++ b/Cython/Compiler/ParseTreeTransforms.py @@ -708,7 +708,7 @@ property NAME: def visit_FuncDefNode(self, node): self.seen_vars_stack.append(set()) - lenv = node.create_local_scope(self.env_stack[-1]) + lenv = node.local_scope node.body.analyse_control_flow(lenv) # this will be totally refactored node.declare_arguments(lenv) for var, type_node in node.directive_locals.items(): -- 2.26.2