From: Robert Bradshaw Date: Sat, 7 Mar 2009 23:30:53 +0000 (-0800) Subject: Better cpdef override check (use method in C API rather than strcmp). X-Git-Tag: 0.11.rc~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=688088fb84b1619ef23b64247b043ff2ad0ddf58;p=cython.git Better cpdef override check (use method in C API rather than strcmp). --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 2db5e90a..f88c8b0e 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -2477,8 +2477,7 @@ class OverrideCheckNode(StatNode): # need to get attribute manually--scope would return cdef method code.putln("%s = PyObject_GetAttr(%s, %s); %s" % (self.func_node.result(), self_arg, self.py_func.interned_attr_cname, err)) code.put_gotref(self.func_node.py_result()) - # It appears that this type is not anywhere exposed in the Python/C API - is_builtin_function_or_method = '(strcmp(Py_TYPE(%s)->tp_name, "builtin_function_or_method") == 0)' % self.func_node.result() + is_builtin_function_or_method = 'PyCFunction_Check(%s)' % self.func_node.result() is_overridden = '(PyCFunction_GET_FUNCTION(%s) != (void *)&%s)' % (self.func_node.result(), self.py_func.entry.func_cname) code.putln('if (!%s || %s) {' % (is_builtin_function_or_method, is_overridden)) self.body.generate_execution_code(code)