Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A new test case failure can be added.
f"{6 0}"
The old parser will try to send "6 0" into the parser for f-string, thus will raise an SyntaxError like
The new parser will (force) except
}
right after6
. Thus the error message would beThe new parser cannot match the
invalid_*
at the first round, butp->error_indicator
was set to1
, thus it cannot perform the second round.https://github.com/python/cpython/blob/0708437ad043657f992cb985fd5c37e1ac052f93/Parser/pegen.c#L835-L840
So I made some changes to the grammar file to avoid setting
p->error_indicator
in that case.As for the original test case,
Even with this change, the new parser will output
rather than the old parser's
After some digging, this error was improperly hijacked by the tokenizer:
https://github.com/python/cpython/blob/0708437ad043657f992cb985fd5c37e1ac052f93/Parser/pegen_errors.c#L406-L416
I think we should just leave it here, it is acceptable.