summaryrefslogtreecommitdiffstats
path: root/Python/ast.c
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2007-12-09 21:49:48 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2007-12-09 21:49:48 (GMT)
commit40d3a67a190ad1e1f49e123072abd7f4757fdf22 (patch)
treed1af05e91e318b9c8f6c1394f9eb688a929fb6a9 /Python/ast.c
parent3279b5df3c41f5a6a431e60dcca57cdcdb7808e3 (diff)
downloadcpython-40d3a67a190ad1e1f49e123072abd7f4757fdf22.zip
cpython-40d3a67a190ad1e1f49e123072abd7f4757fdf22.tar.gz
cpython-40d3a67a190ad1e1f49e123072abd7f4757fdf22.tar.bz2
Issue #1573, second attempt:
"def f(*, **kw)" now raises a SyntaxError.
Diffstat (limited to 'Python/ast.c')
-rw-r--r--Python/ast.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 0127281..f32f587 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -649,8 +649,12 @@ handle_keywordonly_args(struct compiling *c, const node *n, int start,
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 @@ ast_for_arguments(struct compiling *c, const node *n)
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 */