Repository navigation
Preserve generator scopes in lambda qualified names - #113
Merged
alexmojaki merged 2 commits intoNov 26, 2026
Merged
Conversation
Visit generator-expression scopes explicitly while evaluating the first iterable in its enclosing scope. Preserve PyPy locals and cover nested lambda and generator contexts. Assisted-by: OpenAI Codex
15r10nk
reviewed
Nov 26, 2026
|
|
||
| For a lambda created in a generator expression, the qualified name includes | ||
| its generator scope, such as `<genexpr>.<lambda>` on CPython. Lambdas in the outermost | ||
| iterable expression retain the enclosing scope. |
Collaborator
There was a problem hiding this comment.
This pr fixes the implementation. Keeping a list of all the edge cases which are fixed in the readme is not a good idea.
just delete it.
Contributor
Author
There was a problem hiding this comment.
Makes sense, removed it in 5ef4949. The PR is now just the implementation change and the tests.
The change fixes the implementation; the README does not need to list the edge case.
Collaborator
|
@alexmojaki this one looks ok to me. we can merge it when you agree. |
Contributor
Author
|
Thanks for merging, @alexmojaki, and thanks @15r10nk for the review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and change
Source.code_qualname()omits the generator-expression scope from lambdas created in a generator body, filter, or later iterable. For example,list((lambda: None) for _ in range(1))[0]has the CPython qualname<genexpr>.<lambda>, but the current implementation reports<lambda>. This can mislabel frames in clients such as the Sentry executing integration.Visit the outermost iterable in the enclosing scope and the remaining generator nodes inside
<genexpr>. Preserve PyPy's additional<locals>component. Add 27 regression cases across module, function, and class scopes, including nested generators/lambdas and outer-iterable controls.Validation
PYTHONUTF8=1 EXECUTING_SLOW_TESTS=1 python -m pytest -q tests: 281 passed, 6 skipped. Same environment on the original implementation: 254 passed, 6 skipped.The initial Windows default-encoding run hit a GBK decoding failure in the existing source-file test; UTF-8 mode resolves that environment issue. Full tox interpreter coverage and the pre-commit wrapper were not run; the exact configured formatting hook was run directly. No final coverage percentage is claimed.
AI assistance
Developed and checked with OpenAI Codex, including AI-assisted implementation, tests, and independent review, under the account owner's authorization. No claim of a separate human code review is made.