From: Robert Bradshaw Date: Wed, 29 Oct 2008 04:33:44 +0000 (-0700) Subject: more arg parsing fixes X-Git-Tag: 0.9.9.2.beta~2^2~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3bb75c45c95ccf56106097240728061803244289;p=cython.git more arg parsing fixes --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 9e6b2b2a..bfe9b410 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -1976,16 +1976,15 @@ class DefNode(FuncDefNode): code.put('case %2d: ' % (i+1)) item = "PyTuple_GET_ITEM(%s, %d)" % (Naming.args_cname, i) self.generate_arg_assignment(arg, item, code) + if min_positional_args == 0: + code.put('case 0: ') + code.putln('break;') if self.star_arg: if min_positional_args: - code.putln('break;') for i in range(min_positional_args-1, -1, -1): code.putln('case %2d:' % i) code.put_goto(argtuple_error_label) else: - if min_positional_args == 0: - code.put('case 0: ') - code.putln('break;') code.put('default: ') code.put_goto(argtuple_error_label) code.putln('}') diff --git a/tests/run/callargs.pyx b/tests/run/callargs.pyx index 05ea79d6..fa44e649 100644 --- a/tests/run/callargs.pyx +++ b/tests/run/callargs.pyx @@ -110,9 +110,25 @@ __doc__ = u""" 1 2 0 1 >>> d(1,2,3, key=None) 1 2 1 1 - + + >>> c() + 10 20 0 + >>> c(1) + 1 20 0 + >>> c(1,2) + 1 2 0 + >>> c(key=None) + 10 20 1 + >>> c(1, key=None) + 1 20 1 + >>> c(1,2, key=None) + 1 2 1 + """ +def c(a=10, b=20, **kwds): + print a, b, len(kwds) + def d(a, b=1, *args, **kwds): print a, b, len(args), len(kwds)