-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-119666: fix multiple class-scope comprehensions referencing __class__ #120295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Is there any chance this also fixes #119233? |
Fine with me. I think the test cases here probably cover both reproducers? |
Yeah, the essence of both reproducers is the same: >1 comprehension, in class scope, referencing |
Thanks @carljm for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
…__class__ (pythonGH-120295) (cherry picked from commit 0ae8579) Co-authored-by: Carl Meyer <carl@oddbird.net>
GH-120299 is a backport of this pull request to the 3.13 branch. |
…__class__ (pythonGH-120295) (cherry picked from commit 0ae8579) Co-authored-by: Carl Meyer <carl@oddbird.net>
GH-120300 is a backport of this pull request to the 3.12 branch. |
It took a few months, but the fuzzer discovered that the fix in #115139 was not quite sufficient. It was only applied in the case where the
__class__
symbol did not exist in the outer class scope, but it actually needs to be applied regardless.Verified that all listcomp tests (apart from
test_frame_locals
, which is now intentionally diverging from pre-3.12 comprehension behavior, since the implementation of PEP 667) pass both with comprehension inlining enabled and disabled, so they reflect the same behavior as before Python 3.12.