Commit 521350d4 authored by Stefan Behnel's avatar Stefan Behnel

fix ticket #589: bound methods of optimised builtin types

parent fb8b5c7e
...@@ -320,8 +320,8 @@ class BuiltinMethod(_BuiltinOverride): ...@@ -320,8 +320,8 @@ class BuiltinMethod(_BuiltinOverride):
self_arg = PyrexTypes.CFuncTypeArg("", self_type, None) self_arg = PyrexTypes.CFuncTypeArg("", self_type, None)
self_arg.not_none = True self_arg.not_none = True
method_type = sig.function_type(self_arg) method_type = sig.function_type(self_arg)
self_type.scope.declare_cfunction(self.py_name, method_type, None, self.cname, self_type.scope.declare_builtin_cfunction(
utility_code = self.utility_code) self.py_name, method_type, self.cname, utility_code = self.utility_code)
builtin_function_table = [ builtin_function_table = [
......
...@@ -1587,6 +1587,19 @@ class CClassScope(ClassScope): ...@@ -1587,6 +1587,19 @@ class CClassScope(ClassScope):
entry.prev_entry = prev_entry entry.prev_entry = prev_entry
return entry return entry
def declare_builtin_cfunction(self, name, type, cname, utility_code = None):
# overridden methods of builtin types still have their Python
# equivalent that must be accessible to support bound methods
name = EncodedString(name)
entry = self.declare_cfunction(name, type, None, cname, visibility='extern',
utility_code = utility_code)
var_entry = Entry(name, name, py_object_type)
var_entry.is_variable = 1
var_entry.is_builtin = 1
var_entry.utility_code = utility_code
entry.as_variable = var_entry
return entry
def declare_property(self, name, doc, pos): def declare_property(self, name, doc, pos):
entry = self.lookup_here(name) entry = self.lookup_here(name)
if entry is None: if entry is None:
......
...@@ -16,7 +16,6 @@ with_statement_module_level_T536 ...@@ -16,7 +16,6 @@ with_statement_module_level_T536
function_as_method_T494 function_as_method_T494
closure_inside_cdef_T554 closure_inside_cdef_T554
ipow_crash_T562 ipow_crash_T562
bound_builtin_methods_T589
# CPython regression tests that don't current work: # CPython regression tests that don't current work:
......
cimport cython cimport cython
_set = set # CPython may not define it (in Py2.3), but Cython does :)
def test_set_clear_bound(): def test_set_clear_bound():
""" """
>>> type(test_set_clear_bound()) is _set >>> type(test_set_clear_bound()) is _set
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment