From 34aa95a4852fcee35249ad1bdb698e5777a77571 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Tue, 12 Feb 2008 21:38:47 -0800 Subject: [PATCH] Real fix for builtins caching + coercion bug (as reported by paul.metcalfe@gmail.com) --- Cython/Compiler/ExprNodes.py | 2 ++ Cython/Compiler/Symtab.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index f7736536..a2299a61 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -773,6 +773,8 @@ class NameNode(AtomicExprNode): if entry and entry.is_cfunction: var_entry = entry.as_variable if var_entry: + if var_entry.is_builtin and Options.cache_builtins: + var_entry = env.declare_builtin(var_entry.name, self.pos) node = NameNode(self.pos, name = self.name) node.entry = var_entry node.analyse_rvalue_entry(env) diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index af770fc7..7ad19b9f 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -717,10 +717,15 @@ class ModuleScope(Scope): return self.outer_scope.declare_builtin(name, pos) else: error(pos, "undeclared name not builtin: %s"%name) - entry = self.declare(name, name, py_object_type, pos) + if Options.cache_builtins: + for entry in self.cached_builtins: + if entry.name == name: + return entry + entry = self.declare(None, None, py_object_type, pos) if Options.cache_builtins: entry.is_builtin = 1 entry.is_const = 1 + entry.name = name entry.cname = Naming.builtin_prefix + name self.cached_builtins.append(entry) self.undeclared_cached_builtins.append(entry) -- 2.26.2