diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2015-08-05 21:54:10 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2015-08-05 21:54:10 (GMT) |
commit | 14acf5f41d2c9b4ec9c0f3219bc9553c31fd9a9f (patch) | |
tree | cdeed9e5dc49aaa22c8596304a1284d4135c9036 /Python/ast.c | |
parent | cedef652fa94f28e9d37eefd8ce6a2f0401f5f45 (diff) | |
download | cpython-14acf5f41d2c9b4ec9c0f3219bc9553c31fd9a9f.zip cpython-14acf5f41d2c9b4ec9c0f3219bc9553c31fd9a9f.tar.gz cpython-14acf5f41d2c9b4ec9c0f3219bc9553c31fd9a9f.tar.bz2 |
Issue #24791: Fix grammar regression for call syntax: 'g(*a or b)'.
Diffstat (limited to 'Python/ast.c')
-rw-r--r-- | Python/ast.c | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/Python/ast.c b/Python/ast.c index bb28437..b572088 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -2664,45 +2664,44 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func) expr_ty e; node *chch = CHILD(ch, 0); if (NCH(ch) == 1) { - if (TYPE(chch) == star_expr) { - /* an iterable argument unpacking */ - expr_ty starred; + /* a positional argument */ + if (nkeywords) { if (ndoublestars) { ast_error(c, chch, - "iterable argument unpacking follows " + "positional argument follows " "keyword argument unpacking"); - return NULL; } - e = ast_for_expr(c, CHILD(chch, 1)); - if (!e) - return NULL; - starred = Starred(e, Load, LINENO(chch), - chch->n_col_offset, - c->c_arena); - if (!starred) - return NULL; - asdl_seq_SET(args, nargs++, starred); - } - else { - /* a positional argument */ - if (nkeywords) { - if (ndoublestars) { - ast_error(c, chch, - "positional argument follows " - "keyword argument unpacking"); - } - else { - ast_error(c, chch, - "positional argument follows " - "keyword argument"); - } - return NULL; + else { + ast_error(c, chch, + "positional argument follows " + "keyword argument"); } - e = ast_for_expr(c, chch); - if (!e) - return NULL; - asdl_seq_SET(args, nargs++, e); + return NULL; } + e = ast_for_expr(c, chch); + if (!e) + return NULL; + asdl_seq_SET(args, nargs++, e); + } + else if (TYPE(chch) == STAR) { + /* an iterable argument unpacking */ + expr_ty starred; + if (ndoublestars) { + ast_error(c, chch, + "iterable argument unpacking follows " + "keyword argument unpacking"); + return NULL; + } + e = ast_for_expr(c, CHILD(ch, 1)); + if (!e) + return NULL; + starred = Starred(e, Load, LINENO(chch), + chch->n_col_offset, + c->c_arena); + if (!starred) + return NULL; + asdl_seq_SET(args, nargs++, starred); + } else if (TYPE(chch) == DOUBLESTAR) { /* a keyword argument unpacking */ |