From c66708bdc688f2bf47981295e5c6a037252d470b Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 15 Apr 2011 15:56:49 +0200 Subject: [PATCH] make auto_cpdef play nicely with closure functions --- Cython/Compiler/Main.py | 2 +- Cython/Compiler/ParseTreeTransforms.py | 6 ++++-- tests/bugs.txt | 1 - 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py index 993d8d99..6b5deaee 100644 --- a/Cython/Compiler/Main.py +++ b/Cython/Compiler/Main.py @@ -135,8 +135,8 @@ class Context(object): PostParse(self), _specific_post_parse, InterpretCompilerDirectives(self, self.compiler_directives), - _align_function_definitions, MarkClosureVisitor(self), + _align_function_definitions, ConstantFolding(), FlattenInListTransform(), WithTransform(self), diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py index 8f686735..1f3bbf30 100644 --- a/Cython/Compiler/ParseTreeTransforms.py +++ b/Cython/Compiler/ParseTreeTransforms.py @@ -1425,9 +1425,11 @@ class AlignFunctionDefinitions(CythonTransform): error(pxd_def.pos, "previous declaration here") return None node = node.as_cfunction(pxd_def) - elif self.scope.is_module_scope and self.directives['auto_cpdef']: + elif (self.scope.is_module_scope + and not node.needs_closure + and self.directives['auto_cpdef']): node = node.as_cfunction(scope=self.scope) - # Enable this when internal def functions are allowed. + # Enable this when nested cdef functions are allowed. # self.visitchildren(node) return node diff --git a/tests/bugs.txt b/tests/bugs.txt index 2aeadbff..2aa611e0 100644 --- a/tests/bugs.txt +++ b/tests/bugs.txt @@ -19,7 +19,6 @@ for_from_pyvar_loop_T601 decorators_T593 temp_sideeffects_T654 class_scope_T671 -auto_cpdef_closures # CPython regression tests that don't current work: pyregr.test_threadsignals -- 2.26.2