gh-85560: Fix IDLE paren matching with "else" or "yield" at the start of a continuation line - #157693
Open
serhiy-storchaka wants to merge 3 commits into
Open
serhiy-storchaka wants to merge 3 commits into
serhiy-storchaka wants to merge 3 commits into
Conversation
… continuation line pyparse took a line starting with "else" for the start of a statement, so the parenthesis containing a conditional expression continued on such a line was not found. Now "else" is a statement start only if it is followed by a colon.
… start of a continuation line pyparse took a line starting with "else" or "yield" for the start of a statement, so the parenthesis containing a conditional expression or a yield expression continued on such a line was not found. Now "else" is a statement start only if it is followed by a colon, and "yield" is not a statement start.
"with", "del", "global", "nonlocal", "pass" and "finally" cannot start a continuation line, so they are safe synchronization points, and let find_good_parse_start() cut the parsed text closer to its end.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
pyparse._synchretook any line starting withelseoryieldfor the start of a statement, so the parenthesis containing a conditional expression or a yield expression continued on such a line ((1 if x\n else 0),(\n yield x)) was not found by Show Surrounding Parens. Anelsestatement is always followed by a colon, a conditional expression never, soelsenow counts as a statement start only when followed by:. Ayieldstatement cannot be told from a yield expression, soyieldis removed from the list; it only served to shorten the parsed text. On the other hand,with,del,global,nonlocal,passandfinally, which cannot start a continuation line, are added.🤖 Generated with Claude Code