Real fix for builtins caching + coercion bug (as reported by paul.metcalfe@gmail...
authorRobert Bradshaw <robertwb@math.washington.edu>
Wed, 13 Feb 2008 05:38:47 +0000 (21:38 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Wed, 13 Feb 2008 05:38:47 +0000 (21:38 -0800)
Cython/Compiler/ExprNodes.py
Cython/Compiler/Symtab.py

index f7736536315b8d9409831f9da487006a5ccc0433..a2299a61291cb404e1f70ee81338f176022b6a1c 100644 (file)
@@ -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)
index af770fc77b4927649581b08325573180cbc0e790..7ad19b9fdce73d0572c9731c7146a7959b116580 100644 (file)
@@ -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)