From: Stefan Behnel Date: Fri, 4 Dec 2009 06:45:15 +0000 (+0100) Subject: fix compiler crashes on unknown functions X-Git-Tag: 0.12.1~96 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0a33f1e60428979747d0a8051cd226be35b94414;p=cython.git fix compiler crashes on unknown functions --- diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index dd4d3d0a..57864d5f 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -118,7 +118,7 @@ class IterationTransform(Visitor.VisitorTransform): # enumerate() ? if iterator.self is None and \ isinstance(function, ExprNodes.NameNode) and \ - function.entry.is_builtin and \ + function.entry and function.entry.is_builtin and \ function.name == 'enumerate': return self._transform_enumerate_iteration(node, iterator) @@ -126,7 +126,7 @@ class IterationTransform(Visitor.VisitorTransform): if Options.convert_range and node.target.type.is_int: if iterator.self is None and \ isinstance(function, ExprNodes.NameNode) and \ - function.entry.is_builtin and \ + function.entry and function.entry.is_builtin and \ function.name in ('range', 'xrange'): return self._transform_range_iteration(node, iterator) @@ -831,6 +831,8 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform): # we only consider functions that are either builtin # Python functions or builtins that were already replaced # into a C function call (defined in the builtin scope) + if not function.entry: + return node is_builtin = function.entry.is_builtin \ or getattr(function.entry, 'scope', None) is Builtin.builtin_scope if not is_builtin: