Commit 3bb75c45 authored by Robert Bradshaw's avatar Robert Bradshaw

more arg parsing fixes

parent b7a4e7ab
...@@ -1976,16 +1976,15 @@ class DefNode(FuncDefNode): ...@@ -1976,16 +1976,15 @@ class DefNode(FuncDefNode):
code.put('case %2d: ' % (i+1)) code.put('case %2d: ' % (i+1))
item = "PyTuple_GET_ITEM(%s, %d)" % (Naming.args_cname, i) item = "PyTuple_GET_ITEM(%s, %d)" % (Naming.args_cname, i)
self.generate_arg_assignment(arg, item, code) self.generate_arg_assignment(arg, item, code)
if min_positional_args == 0:
code.put('case 0: ')
code.putln('break;')
if self.star_arg: if self.star_arg:
if min_positional_args: if min_positional_args:
code.putln('break;')
for i in range(min_positional_args-1, -1, -1): for i in range(min_positional_args-1, -1, -1):
code.putln('case %2d:' % i) code.putln('case %2d:' % i)
code.put_goto(argtuple_error_label) code.put_goto(argtuple_error_label)
else: else:
if min_positional_args == 0:
code.put('case 0: ')
code.putln('break;')
code.put('default: ') code.put('default: ')
code.put_goto(argtuple_error_label) code.put_goto(argtuple_error_label)
code.putln('}') code.putln('}')
......
...@@ -110,9 +110,25 @@ __doc__ = u""" ...@@ -110,9 +110,25 @@ __doc__ = u"""
1 2 0 1 1 2 0 1
>>> d(1,2,3, key=None) >>> d(1,2,3, key=None)
1 2 1 1 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): def d(a, b=1, *args, **kwds):
print a, b, len(args), len(kwds) print a, b, len(args), len(kwds)
......
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