Skip to content

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

Merged
merged 2 commits into from
Jun 10, 2024

Conversation

carljm
Copy link
Member

@carljm carljm commented Jun 9, 2024

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.

@alex
Copy link
Member

alex commented Jun 9, 2024

Is there any chance this also fixes #119233?

@carljm
Copy link
Member Author

carljm commented Jun 9, 2024

Is there any chance this also fixes #119233?

Yes, just confirmed that it does. Ok if I close that as duplicate of #119666?

@alex
Copy link
Member

alex commented Jun 9, 2024

Fine with me. I think the test cases here probably cover both reproducers?

@carljm
Copy link
Member Author

carljm commented Jun 9, 2024

Yeah, the essence of both reproducers is the same: >1 comprehension, in class scope, referencing super or __class__.

@carljm carljm merged commit 0ae8579 into python:main Jun 10, 2024
40 checks passed
@miss-islington-app
Copy link

Thanks @carljm for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

@carljm carljm deleted the classcell branch June 10, 2024 02:23
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 10, 2024
…__class__ (pythonGH-120295)

(cherry picked from commit 0ae8579)

Co-authored-by: Carl Meyer <carl@oddbird.net>
@bedevere-app
Copy link

bedevere-app bot commented Jun 10, 2024

GH-120299 is a backport of this pull request to the 3.13 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 10, 2024
…__class__ (pythonGH-120295)

(cherry picked from commit 0ae8579)

Co-authored-by: Carl Meyer <carl@oddbird.net>
@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jun 10, 2024
@bedevere-app
Copy link

bedevere-app bot commented Jun 10, 2024

GH-120300 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Jun 10, 2024
carljm pushed a commit that referenced this pull request Jun 10, 2024
carljm pushed a commit that referenced this pull request Jun 10, 2024
mrahtz pushed a commit to mrahtz/cpython that referenced this pull request Jun 30, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants