Commit 8b7c9fef authored by Stefan Behnel's avatar Stefan Behnel

minor refactoring; fix handling first argument in classmethods; fix ticket...

minor refactoring; fix handling first argument in classmethods; fix ticket #462: allow method(*args) in cdef classes
parent b6804cab
This diff is collapsed.
......@@ -7,4 +7,3 @@ numpy_ValueError_T172
unsignedbehaviour_T184
missing_baseclass_in_predecl_T262
cfunc_call_tuple_args_T408
cdef_methods_T462
cimport cython
cdef class cclass:
@classmethod
def test0(cls):
"""
>>> cclass.test0()
'type object'
"""
return cython.typeof(cls)
@classmethod
def test0_args(*args):
"""
>>> cclass.test0_args(1,2,3)
('Python object', (1, 2, 3))
"""
return cython.typeof(args[0]), args[1:]
@classmethod
def test1(cls, arg):
"""
>>> cclass.test1(1)
('type object', 1)
"""
return cython.typeof(cls), arg
@classmethod
def test2(cls, arg1, arg2):
"""
>>> cclass.test2(1,2)
('type object', 1, 2)
"""
return cython.typeof(cls), arg1, arg2
@classmethod
def test1_args(cls, *args):
"""
>>> cclass.test1_args(1,2,3)
('type object', (1, 2, 3))
"""
return cython.typeof(cls), args
@classmethod
def test2_args(cls, arg, *args):
"""
>>> cclass.test2_args(1,2,3)
('type object', 1, (2, 3))
"""
return cython.typeof(cls), arg, args
@classmethod
def test0_args_kwargs(*args, **kwargs):
"""
>>> cclass.test0_args_kwargs(1,2,3)
('Python object', (1, 2, 3), {})
"""
return cython.typeof(args[0]), args[1:], kwargs
@classmethod
def test1_args_kwargs(cls, *args, **kwargs):
"""
>>> cclass.test1_args_kwargs(1,2,3)
('type object', (1, 2, 3), {})
"""
return cython.typeof(cls), args, kwargs
@classmethod
def test2_args_kwargs(cls, arg, *args, **kwargs):
"""
>>> cclass.test2_args_kwargs(1,2,3)
('type object', 1, (2, 3), {})
"""
return cython.typeof(cls), arg, args, kwargs
......@@ -12,20 +12,27 @@ cdef class cclass:
def test_self_1(self, arg):
"""
>>> cclass().test_self_1(1)
('cclass', (1,))
('cclass', 1)
"""
return cython.typeof(self), arg
def test_self_args(self, *args):
"""
>>> cclass().normal_test1_args(1,2,3)
>>> cclass().test_self_args(1,2,3)
('cclass', (1, 2, 3))
"""
return cython.typeof(self), args
def test_args(*args):
"""
>>> cclass().normal_test0_args(1,2,3):
("Python object", (1, 2, 3))
>>> cclass().test_args(1,2,3)
('Python object', (1, 2, 3))
"""
return cython.typeof(args[0]), args[1:]
def test_args_kwargs(*args, **kwargs):
"""
>>> cclass().test_args_kwargs(1,2,3, a=4)
('Python object', (1, 2, 3), {'a': 4})
"""
return cython.typeof(args[0]), args[1:], kwargs
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