Skip to content

gh-135617: Clarify starred targets in with statements - #159838

Open
limadog9 wants to merge 1 commit into
python:mainfrom
limadog9:gh-135617-with-star-target-docs
Open

limadog9 wants to merge 1 commit into
python:mainfrom
limadog9:gh-135617-with-star-target-docs

Conversation

@limadog9

@limadog9 limadog9 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Clarify the constraint on starred targets after with ... as: a starred target must be part of a list or tuple target. Show the valid [*items] and (*items,) forms and explain that a bare *items is invalid.

Link the rule to assignment targets without adding a separate grammar production.

Fixes #135617.

Validation:

  • Compiled and executed five valid target forms and confirmed that three invalid starred forms raise SyntaxError on the current CPython build.
  • Full HTML documentation build with warnings treated as errors.
  • Sphinx lint and patchcheck.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35258519 | 📁 Comparing b035376 against main (0fba211)

  🔍 Preview build  

1 file changed
± reference/compound_stmts.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

with statement star target

1 participant