Commit 368ddfc3 authored by Stefan Behnel's avatar Stefan Behnel

fix #683: allow overriding C-API mapped builtin functions with (auto-)cpdef functions

parent 4e192e34
......@@ -1418,7 +1418,7 @@ class AlignFunctionDefinitions(CythonTransform):
def visit_DefNode(self, node):
pxd_def = self.scope.lookup(node.name)
if pxd_def:
if pxd_def and (not pxd_def.scope or not pxd_def.scope.is_builtin_scope):
if not pxd_def.is_cfunction:
error(node.pos, "'%s' redeclared" % node.name)
if pxd_def.pos:
......
# cython: auto_cpdef=True
# mode:run
# tag: directive,auto_cpdef
import cython
def str(arg):
"""
This is a bit evil - str gets mapped to a C-API function and is
being redefined here.
>>> print(str('TEST'))
STR
"""
return 'STR'
@cython.test_assert_path_exists('//SimpleCallNode[@function.type.is_cfunction = True]')
@cython.test_fail_if_path_exists('//SimpleCallNode[@function.type.is_builtin_type = True]')
def call_str(arg):
"""
>>> print(call_str('TEST'))
STR
"""
return str(arg)
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