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): ...@@ -1756,12 +1756,8 @@ class DefNode(FuncDefNode):
code.putln('case %d:' % (i+1)) code.putln('case %d:' % (i+1))
code.putln("values[%d] = PyTuple_GET_ITEM(%s, %d);" % ( code.putln("values[%d] = PyTuple_GET_ITEM(%s, %d);" % (
i, Naming.args_cname, i)) i, Naming.args_cname, i))
if self.star_arg: code.putln('case 0: break;')
code.putln('case 0: break;') if not self.star_arg:
else:
if min_positional_args == 0:
code.putln('case 0:')
code.putln('break;')
code.put('default: ') # more arguments than allowed code.put('default: ') # more arguments than allowed
code.put_goto(argtuple_error_label) code.put_goto(argtuple_error_label)
code.putln('}') code.putln('}')
......
__doc__ = u""" __doc__ = u"""
>>> call0abc(b)
1 2 3
>>> call3(b) >>> call3(b)
1 2 3 1 2 3
>>> call4(b) >>> call4(b)
Traceback (most recent call last): Traceback (most recent call last):
TypeError: b() takes exactly 3 positional arguments (4 given) TypeError: b() takes exactly 3 positional arguments (4 given)
>>> call0ab(c)
1 2 1
>>> call0abc(c)
1 2 3
>>> call2(c) >>> call2(c)
1 2 1 1 2 1
>>> call3(c) >>> call3(c)
...@@ -13,6 +19,8 @@ __doc__ = u""" ...@@ -13,6 +19,8 @@ __doc__ = u"""
Traceback (most recent call last): Traceback (most recent call last):
TypeError: c() takes at most 3 positional arguments (4 given) TypeError: c() takes at most 3 positional arguments (4 given)
>>> call0abc(d)
1 2 3
>>> call2(d) >>> call2(d)
1 2 88 1 2 88
>>> call2c(d) >>> call2c(d)
...@@ -25,6 +33,8 @@ __doc__ = u""" ...@@ -25,6 +33,8 @@ __doc__ = u"""
Traceback (most recent call last): Traceback (most recent call last):
TypeError: 'd' is an invalid keyword argument for this function TypeError: 'd' is an invalid keyword argument for this function
>>> call0abc(e)
1 2 3 []
>>> call2(e) >>> call2(e)
1 2 88 [] 1 2 88 []
>>> call2c(e) >>> call2c(e)
...@@ -39,6 +49,8 @@ __doc__ = u""" ...@@ -39,6 +49,8 @@ __doc__ = u"""
Traceback (most recent call last): Traceback (most recent call last):
TypeError: e() takes at most 3 positional arguments (4 given) TypeError: e() takes at most 3 positional arguments (4 given)
>>> call0abc(f)
1 2 3 42
>>> call2c(f) >>> call2c(f)
1 2 1 42 1 2 1 42
>>> call2cd(f) >>> call2cd(f)
...@@ -106,6 +118,12 @@ __doc__ = u""" ...@@ -106,6 +118,12 @@ __doc__ = u"""
# the calls: # the calls:
def call0ab(f):
f(a=1,b=2)
def call0abc(f):
f(a=1,b=2,c=3)
def call2(f): def call2(f):
f(1,2) 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