From: Stefan Behnel Date: Mon, 25 Aug 2008 07:34:01 +0000 (+0200) Subject: fix: passing all positional arguments as kw-args was broken X-Git-Tag: 0.9.9.2.beta~63^2~34 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=871351b566546eb276c4d2e02dce6e0f1ac40f8d;p=cython.git fix: passing all positional arguments as kw-args was broken --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 9db7897e..d3596ea2 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -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;') + 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('}') diff --git a/tests/run/kwonlyargscall.pyx b/tests/run/kwonlyargscall.pyx index 910a5c04..22fa29a6 100644 --- a/tests/run/kwonlyargscall.pyx +++ b/tests/run/kwonlyargscall.pyx @@ -1,10 +1,16 @@ __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)