diff Python/ast.c @ 44246:aac33ee1a8fc

Issue #1573, second attempt: "def f(*, **kw)" now raises a SyntaxError.
author Amaury Forgeot d'Arc <amauryfa@gmail.com>
date Sun, 09 Dec 2007 21:49:48 +0000
parents 44a24b59b16d
children 86a2679dca46
line wrap: on
line diff
--- a/Python/ast.c	Sun Dec 09 15:58:13 2007 +0000
+++ b/Python/ast.c	Sun Dec 09 21:49:48 2007 +0000
@@ -649,8 +649,12 @@
     arg_ty arg;
     int i = start;
     int j = 0; /* index for kwdefaults and kwonlyargs */
-    assert((kwonlyargs != NULL && kwdefaults != NULL) ||
-           TYPE(CHILD(n, i)) == DOUBLESTAR);
+
+    if (kwonlyargs == NULL) {
+        ast_error(CHILD(n, start), "named arguments must follow bare *");
+        return -1;
+    }
+    assert(kwdefaults != NULL);
     while (i < NCH(n)) {
         ch = CHILD(n, i);
         switch (TYPE(ch)) {
@@ -814,7 +818,8 @@
                 break;
             case STAR:
                 if (i+1 >= NCH(n)) {
-                    ast_error(CHILD(n, i), "no name for vararg");
+                    ast_error(CHILD(n, i), 
+                        "named arguments must follow bare *");
                     goto error;
                 }
                 ch = CHILD(n, i+1);  /* tfpdef or COMMA */