From 0ebc91f2c644fe4b2929fd1cc6fbe1f65a45243a Mon Sep 17 00:00:00 2001 From: Robert Bradshaw <robertwb@gmail.com> Date: Tue, 29 Apr 2014 00:45:58 -0700 Subject: [PATCH] Fix self arg type when adding optional arguments in an override. --- Cython/Compiler/PyrexTypes.py | 2 -- tests/run/cdefoptargs.pyx | 30 +++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 27d8b2344..7ee2a98de 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -2445,8 +2445,6 @@ class CFuncType(CType): 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 diff --git a/tests/run/cdefoptargs.pyx b/tests/run/cdefoptargs.pyx index e79e1879f..94062ad1e 100644 --- a/tests/run/cdefoptargs.pyx +++ b/tests/run/cdefoptargs.pyx @@ -1,4 +1,4 @@ -# the calls: +from cython cimport typeof def call2(): """ @@ -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 -- 2.30.9