mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-88535: Improve syntax error for wrongly closed strings (#26633)
This commit is contained in:
parent
56eda25633
commit
6fb5138776
6 changed files with 1098 additions and 930 deletions
|
@ -1178,6 +1178,9 @@ invalid_type_param:
|
|||
}
|
||||
|
||||
invalid_expression:
|
||||
| STRING a=(!STRING expression_without_invalid)+ STRING {
|
||||
RAISE_SYNTAX_ERROR_KNOWN_RANGE( PyPegen_first_item(a, expr_ty), PyPegen_last_item(a, expr_ty),
|
||||
"invalid syntax. Is this intended to be part of the string?") }
|
||||
# !(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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue