diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2021-11-24 22:21:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-24 22:21:23 (GMT) |
commit | 24c10d2943c482c4d3ecc71d45df2d8c10fa5bb1 (patch) | |
tree | bcd92d5aa5eb38532813cd703dc7f728d20d230a /Grammar | |
parent | f4afc53bf68c8ded20b281cd1baa88a679b4a3fd (diff) | |
download | cpython-24c10d2943c482c4d3ecc71d45df2d8c10fa5bb1.zip cpython-24c10d2943c482c4d3ecc71d45df2d8c10fa5bb1.tar.gz cpython-24c10d2943c482c4d3ecc71d45df2d8c10fa5bb1.tar.bz2 |
bpo-45727: Only trigger the 'did you forgot a comma' error suggestion if inside parentheses (GH-29757)
Diffstat (limited to 'Grammar')
-rw-r--r-- | Grammar/python.gram | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram index 60fbc40..2c696a6 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -1084,7 +1084,8 @@ invalid_expression: # !(NAME STRING) is not matched so we don't show this error with some invalid string prefixes like: kf"dsfsdf" # Soft keywords need to also be ignored because they can be parsed as NAME NAME | !(NAME STRING | SOFT_KEYWORD) a=disjunction b=expression_without_invalid { - _PyPegen_check_legacy_stmt(p, a) ? NULL : RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Perhaps you forgot a comma?") } + _PyPegen_check_legacy_stmt(p, a) ? NULL : p->tokens[p->mark-1]->level == 0 ? NULL : + RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Perhaps you forgot a comma?") } | a=disjunction 'if' b=disjunction !('else'|':') { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "expected 'else' after 'if' expression") } invalid_named_expression: |