From 38ceddfda0d5156d7bc95d2d0320b6c603e486ad Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Wed, 21 Oct 2009 21:30:39 +0200 Subject: [PATCH] fix bug 429: make 'locals' builtin overridable --- Cython/Compiler/ParseTreeTransforms.py | 6 +++++- tests/bugs.txt | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py index 00b47bc7..c760f4d1 100644 --- a/Cython/Compiler/ParseTreeTransforms.py +++ b/Cython/Compiler/ParseTreeTransforms.py @@ -978,8 +978,12 @@ class TransformBuiltinMethods(EnvTransform): # locals builtin if isinstance(node.function, ExprNodes.NameNode): if node.function.name == 'locals': - pos = node.pos lenv = self.env_stack[-1] + entry = lenv.lookup_here('locals') + if entry: + # not the builtin 'locals' + return node + pos = node.pos items = [ExprNodes.DictItemNode(pos, key=ExprNodes.StringNode(pos, value=var), value=ExprNodes.NameNode(pos, name=var)) for var in lenv.entries] diff --git a/tests/bugs.txt b/tests/bugs.txt index dc8b81d0..fed33556 100644 --- a/tests/bugs.txt +++ b/tests/bugs.txt @@ -8,5 +8,4 @@ unsignedbehaviour_T184 bad_c_struct_T252 missing_baseclass_in_predecl_T262 extended_unpacking_T409 -locals_rebind_T429 locals_expressions_T430 -- 2.26.2