Commit 871351b5 authored by Stefan Behnel's avatar Stefan Behnel

fix: passing all positional arguments as kw-args was broken

parent e3d6767d
......@@ -1756,12 +1756,8 @@ class DefNode(FuncDefNode):
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;')
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)
......@@ -13,6 +19,8 @@ __doc__ = u"""
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)
......@@ -25,6 +33,8 @@ __doc__ = u"""
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)
......@@ -39,6 +49,8 @@ __doc__ = u"""
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)
......@@ -106,6 +118,12 @@ __doc__ = u"""
# 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)
......
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