-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-114828: Fix __class__ in class-scope inlined comprehensions #115139
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
9926c62
to
342f89d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Agree this seems rather unlikely to come up in practice.
Thanks @carljm for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
…ythonGH-115139) (cherry picked from commit fedbf77) Co-authored-by: Carl Meyer <carl@oddbird.net>
GH-115140 is a backport of this pull request to the 3.12 branch. |
…GH-115139) (#115140) gh-114828: Fix __class__ in class-scope inlined comprehensions (GH-115139) (cherry picked from commit fedbf77) Co-authored-by: Carl Meyer <carl@oddbird.net>
There's a bunch of compiler warnings in |
I saw that but didn't comment because they looked obviously unrelated. I don't know what made them show up though; @carljm do you have any ideas? |
No, the warnings look very odd to me ( |
I thought they looked unrelated too, but they showed up on the 3.12 backport PR as well |
Ok, after further exploration, this warning is related to the PR, and in fact reveals a bug in the PR. The expression It just happens that this doesn't cause any actual problem, because This is a good reminder to always parenthesize your macro definitions! The best fix IMO would be to parenthesize all of those defines (e.g. The error is mostly confusing because it points to the wrong code location (the macro definition instead of usage site), but digging into the actual compiler logs, the warning points to both locations. Thanks @AlexWaygood for pushing me to dig further into this! I'll push a fix PR. |
The behavior of
__class__
as a cell / freevar is special-cased in various places in the symbol table and the compiler; it needs a bit more special-casing in the comprehension-inlining implementation. This fixes some fuzzer-discovered compilation crashes in code that would rarely if ever make sense to write (usingsuper
in a class-body comprehension.)