more arg parsing fixes
authorRobert Bradshaw <robertwb@math.washington.edu>
Wed, 29 Oct 2008 04:33:44 +0000 (21:33 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Wed, 29 Oct 2008 04:33:44 +0000 (21:33 -0700)
Cython/Compiler/Nodes.py
tests/run/callargs.pyx

index 9e6b2b2a015b0b4e306a48be685d5b7f2f24ab84..bfe9b410247d828a818259cacc6b1f42d27cf769 100644 (file)
@@ -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('}')
index 05ea79d67ffa888c70b2e2e90eb543d935005aff..fa44e649802d9fc872ac239e965647e827809499 100644 (file)
@@ -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)