Skip to content

[pull] main from python:main#1144

Merged
pull[bot] merged 6 commits into
tj-python:mainfrom
python:main
Jun 9, 2026
Merged

[pull] main from python:main#1144
pull[bot] merged 6 commits into
tj-python:mainfrom
python:main

Conversation

@pull

@pull pull Bot commented Jun 9, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

zware and others added 6 commits June 9, 2026 12:26
…n instances (GH-139820)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
…eference `__class__` and friends (#150735)

* Fix class-scope inline comprehensions when nested scopes reference `__class__` and friends

In `inline_comprehension()`, when `__class__` / `__classdict__` /
`__conditional_annotations__` appears as `FREE` in a comprehension's
symbol table because a nested scope captured it (e.g. nested lambdas),
this name is still discarded from `comp_free` unconditionally.

This prevents `drop_class_free()` from seeing it, so the appropriate
`ste_needs_(...)` flag is never set on the enclosing class.
That leads to `codegen_make_closure()` throwing `SystemError` when it
couldn't find `__class__` / `__classdict__` /
`__conditional_annotations__` in the class's cellvars.

From now on we just discard from `comp_free` when no child scope
(e.g. a lambda) still needs the name as `FREE`. When a child scope does
need it, keep it in `comp_free` so `drop_class_free()` can set the
appropriate flag and the class creates the implicit cell.

* Fix tests

* Fix typo

* Fix formatting

* Add test checking validity of `__class__` returned

* Prefer 'used' to 'deferred'
@pull pull Bot locked and limited conversation to collaborators Jun 9, 2026
@pull pull Bot added the ⤵️ pull label Jun 9, 2026
@pull pull Bot merged commit ce916dc into tj-python:main Jun 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants