Skip to content

Commit

Permalink
Fix self arg type when adding optional arguments in an override.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertwb committed Apr 29, 2014
1 parent 68f9263 commit 0ebc91f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 0 additions & 2 deletions Cython/Compiler/PyrexTypes.py
Expand Up @@ -2445,8 +2445,6 @@ def compatible_signature_with_resolved_type(self, other_type, as_cmethod):
if self.nogil != other_type.nogil:
return 0
self.original_sig = other_type.original_sig or other_type
if as_cmethod:
self.args[0] = other_type.args[0]
return 1


Expand Down
30 changes: 29 additions & 1 deletion tests/run/cdefoptargs.pyx
@@ -1,4 +1,4 @@
# the calls:
from cython cimport typeof

def call2():
"""
Expand Down Expand Up @@ -39,3 +39,31 @@ def test_foo():
print foo(1, 2)
print foo(1, 2, 3)
print foo(1, foo(2, 3), foo(4))

cdef class A:
cpdef method(self):
"""
>>> A().method()
'A'
"""
return typeof(self)

cdef class B(A):
cpdef method(self, int x = 0):
"""
>>> B().method()
('B', 0)
>>> B().method(100)
('B', 100)
"""
return typeof(self), x

cdef class C(B):
cpdef method(self, int x = 10):
"""
>>> C().method()
('C', 10)
>>> C().method(100)
('C', 100)
"""
return typeof(self), x

0 comments on commit 0ebc91f

Please sign in to comment.