mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
bpo-34013: Generalize the invalid legacy statement error message (GH-27389)
This commit is contained in:
parent
2f54fbafa6
commit
6948964ecf
6 changed files with 337 additions and 244 deletions
|
@ -847,10 +847,15 @@ expression_without_invalid[expr_ty]:
|
|||
| a=disjunction 'if' b=disjunction 'else' c=expression { _PyAST_IfExp(b, a, c, EXTRA) }
|
||||
| disjunction
|
||||
| lambdef
|
||||
invalid_legacy_expression:
|
||||
| a=NAME b=expression_without_invalid {
|
||||
_PyPegen_check_legacy_stmt(p, a) ? RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "Missing parentheses in call to '%U'.", a->v.Name.id) : NULL}
|
||||
|
||||
invalid_expression:
|
||||
| invalid_legacy_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 {
|
||||
| !(NAME STRING | SOFT_KEYWORD) a=disjunction b=expression_without_invalid {
|
||||
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Perhaps you forgot a comma?") }
|
||||
|
||||
invalid_named_expression:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue