summaryrefslogtreecommitdiff
path: root/tests/run/append.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run/append.pyx')
-rw-r--r--tests/run/append.pyx34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/run/append.pyx b/tests/run/append.pyx
index 1976780d5..dcc3fe7c9 100644
--- a/tests/run/append.pyx
+++ b/tests/run/append.pyx
@@ -1,3 +1,5 @@
+cimport cython
+
class A:
def append(self, x):
print u"appending", x
@@ -94,3 +96,35 @@ def method_name():
'append'
"""
return [].append.__name__
+
+@cython.test_assert_path_exists(
+ '//PythonCapiCallNode')
+def append_optimized(probably_list):
+ """
+ >>> l = []
+ >>> append_optimized(l)
+ >>> l
+ [1]
+ """
+ probably_list.append(1)
+
+cdef class AppendBug:
+ # https://github.com/cython/cython/issues/4828
+ # if the attribute "append" is found it shouldn't be replaced with
+ # __Pyx_PyObject_Append
+ cdef object append
+ def __init__(self, append):
+ self.append = append
+
+@cython.test_fail_if_path_exists(
+ '//PythonCapiCallNode')
+def specific_attribute(AppendBug a):
+ """
+ >>> def append_to_default_arg(a, arg=[]):
+ ... arg.append(a)
+ ... return arg
+ >>> specific_attribute(AppendBug(append_to_default_arg))
+ >>> append_to_default_arg(None)
+ [1, None]
+ """
+ a.append(1)