code.putln('case %d:' % (i+1))
code.putln("values[%d] = PyTuple_GET_ITEM(%s, %d);" % (
i, Naming.args_cname, i))
- if self.star_arg:
- code.putln('case 0: break;')
- else:
- if min_positional_args == 0:
- code.putln('case 0:')
- code.putln('break;')
+ code.putln('case 0: break;')
+ if not self.star_arg:
code.put('default: ') # more arguments than allowed
code.put_goto(argtuple_error_label)
code.putln('}')
__doc__ = u"""
+ >>> call0abc(b)
+ 1 2 3
>>> call3(b)
1 2 3
>>> call4(b)
Traceback (most recent call last):
TypeError: b() takes exactly 3 positional arguments (4 given)
+ >>> call0ab(c)
+ 1 2 1
+ >>> call0abc(c)
+ 1 2 3
>>> call2(c)
1 2 1
>>> call3(c)
Traceback (most recent call last):
TypeError: c() takes at most 3 positional arguments (4 given)
+ >>> call0abc(d)
+ 1 2 3
>>> call2(d)
1 2 88
>>> call2c(d)
Traceback (most recent call last):
TypeError: 'd' is an invalid keyword argument for this function
+ >>> call0abc(e)
+ 1 2 3 []
>>> call2(e)
1 2 88 []
>>> call2c(e)
Traceback (most recent call last):
TypeError: e() takes at most 3 positional arguments (4 given)
+ >>> call0abc(f)
+ 1 2 3 42
>>> call2c(f)
1 2 1 42
>>> call2cd(f)
# the calls:
+def call0ab(f):
+ f(a=1,b=2)
+
+def call0abc(f):
+ f(a=1,b=2,c=3)
+
def call2(f):
f(1,2)