◐ Shell
clean mode source ↗

gh-104374: don't inline comprehensions in non-function scopes by carljm · Pull Request #104519 · python/cpython

This PR updates and adds comprehension tests to mandate the same scoping and name-visibility rules as in Python 3.11, including in class scopes. These are the changes in Lib/tests/test_listcomps.py.

Then there is one change in Python/symtable.c, to only inline comprehensions that occur within functions.

The rest of the PR is purely a partial rollback of #101441, removing those parts of the implementation of PEP 709 that were required only for inlining module and class-level comprehensions.