Skip to content

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

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

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

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 20734734802d7505823c8f2eeafd003d5b7fe4f1)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants