Skip to content

[3.13] gh-85560: Fix IDLE paren matching with "else" or "yield" at the start of a continuation line (GH-157693) - #157961

Merged
terryjreedy merged 1 commit into
python:3.13from
miss-islington:backport-2073473-3.13
Sep 22, 2026
Merged

terryjreedy merged 1 commit into
python:3.13from
miss-islington:backport-2073473-3.13

Conversation

@miss-islington

@miss-islington miss-islington commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

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.
(cherry picked from commit 2073473)

Co-authored-by: Serhiy Storchaka storchaka@gmail.com

… start of a continuation line (pythonGH-157693)

`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.
(cherry picked from commit 2073473)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@terryjreedy
terryjreedy enabled auto-merge (squash) September 22, 2026 18:53
@terryjreedy
terryjreedy merged commit 8cceb10 into python:3.13 Sep 22, 2026
44 checks passed
@miss-islington
miss-islington deleted the backport-2073473-3.13 branch September 22, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants