Skip to content

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
python:mainfrom
serhiy-storchaka:gh-85560-else-synchre
Open

serhiy-storchaka wants to merge 3 commits into
python:mainfrom
serhiy-storchaka:gh-85560-else-synchre

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Sep 17, 2026

Copy link
Copy Markdown
Member

pyparse._synchre took any 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 ((1 if x\n else 0), (\n yield x)) was not found by Show Surrounding Parens. An else statement is always followed by a colon, a conditional expression never, so else now counts as a statement start only when followed by :. A yield statement cannot be told from a yield expression, so yield is removed from the list; it only served to shorten the parsed text. On the other hand, with, del, global, nonlocal, pass and finally, which cannot start a continuation line, are added.

🤖 Generated with Claude Code

… 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.
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Sep 17, 2026
… 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.
@serhiy-storchaka serhiy-storchaka changed the title gh-85560: Fix IDLE paren matching with "else" at the start of a continuation line gh-85560: Fix IDLE paren matching with "else" or "yield" at the start of a continuation line Sep 17, 2026
"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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant