diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2021-08-01 01:10:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-01 01:10:50 (GMT) |
commit | 208a7e957b812ad3b3733791845447677a704f3e (patch) | |
tree | 5af298f98c8ceea7d731ae14f3770e4b6e1fbdc0 /Parser/parser.c | |
parent | b08c48e61745666df9aeee97d8bddbf1e5550627 (diff) | |
download | cpython-208a7e957b812ad3b3733791845447677a704f3e.zip cpython-208a7e957b812ad3b3733791845447677a704f3e.tar.gz cpython-208a7e957b812ad3b3733791845447677a704f3e.tar.bz2 |
bpo-34013: Don't consider a grouped expression when reporting legacy print syntax errors (GH-27521)
Diffstat (limited to 'Parser/parser.c')
-rw-r--r-- | Parser/parser.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Parser/parser.c b/Parser/parser.c index c05fc31..7a106a4 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -18158,7 +18158,7 @@ expression_without_invalid_rule(Parser *p) return _res; } -// invalid_legacy_expression: NAME star_expressions +// invalid_legacy_expression: NAME !'(' star_expressions static void * invalid_legacy_expression_rule(Parser *p) { @@ -18169,21 +18169,23 @@ invalid_legacy_expression_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // NAME star_expressions + { // NAME !'(' star_expressions if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_legacy_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME star_expressions")); + D(fprintf(stderr, "%*c> invalid_legacy_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME !'(' star_expressions")); expr_ty a; expr_ty b; if ( (a = _PyPegen_name_token(p)) // NAME && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 7) // token='(' + && (b = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ invalid_legacy_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME star_expressions")); + D(fprintf(stderr, "%*c+ invalid_legacy_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME !'(' star_expressions")); _res = _PyPegen_check_legacy_stmt ( p , a ) ? RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "Missing parentheses in call to '%U'. Did you mean %U(...)?" , a -> v . Name . id , a -> v . Name . id ) : NULL; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -18194,7 +18196,7 @@ invalid_legacy_expression_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s invalid_legacy_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME star_expressions")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME !'(' star_expressions")); } _res = NULL; done: |