From a5e1b89af3d2f8f5ebc1ea8a8b1090c48179e226 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Sat, 24 Feb 2007 04:44:11 -0800 Subject: [PATCH] disable builtin functions that conflict with type names add dummy py_index for cdef arrays so subexprs valid --- Cython/Compiler/ExprNodes.py | 1 + Cython/Compiler/Symtab.py | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 34fce862..6c47844d 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -1056,6 +1056,7 @@ class IndexNode(ExprNode): self.type = py_object_type self.is_temp = 1 else: + self.py_index = CloneNode(self.index) # so that it exists for subexpr processing if self.base.type.is_ptr or self.base.type.is_array: self.type = self.base.type.base_type else: diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index 5368dffc..0efd91da 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -457,18 +457,31 @@ class BuiltinScope(Scope): entry.is_builtin = 1 return entry + # TODO: built in functions conflict with built in types of same name... + builtin_functions = { "hasattr": ["PyObject_HasAttrString", c_int_type, (py_object_type, c_char_ptr_type)], "cmp": ["PyObject_Compare", c_int_type, (py_object_type, py_object_type), None, True], "repr": ["PyObject_Repr", py_object_type, (py_object_type, ), 0], - "str": ["PyObject_Str", py_object_type, (py_object_type, ), 0], +# "str": ["PyObject_Str", py_object_type, (py_object_type, ), 0], "unicode": ["PyObject_Unicode", py_object_type, (py_object_type, ), 0], "isinstance": ["PyObject_IsInstance", c_int_type, (py_object_type, py_object_type), -1], "hash": ["PyObject_Hash", c_long_type, (py_object_type, ), -1, True], "type": ["PyObject_Type", py_object_type, (py_object_type, ), 0], "len": ["PyObject_Size", c_py_ssize_t_type, (py_object_type, ), -1], "dir": ["PyObject_Dir", py_object_type, (py_object_type, ), 0], - "iter": ["PyObject_GetIter", py_object_type, (py_object_type, ), 0], + "iter": ["PyObject_GetIter", py_object_type, (py_object_type, ), 0], + + "abs": ["PyNumber_Absolute", py_object_type, (py_object_type, ), 0], + "divmod": ["PyNumber_Divmod", py_object_type, (py_object_type, py_object_type), 0], + "pow": ["PyNumber_Power", py_object_type, (py_object_type, py_object_type, py_object_type), 0], +# "int": ["PyNumber_Int", py_object_type, (py_object_type, ), 0], +# "long": ["PyNumber_Long", py_object_type, (py_object_type, ), 0], +# "float": ["PyNumber_Float", py_object_type, (py_object_type, ), 0], + +# "list": ["PyNumber_List", py_object_type, (py_object_type, ), 0], +# "tuple": ["PySequence_Tuple", py_object_type, (py_object_type, ), 0], + } class ModuleScope(Scope): -- 2.26.2