-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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
gh-119311: Fix name mangling with PEP 695 generic classes #119464
Conversation
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.
Looks good to me.
I'm not sure I see why this can't be backported to 3.12. I don't know if we usually bump bytecode magic number in patch releases, but surely that doesn't prevent us from backporting any compiler fixes at all. This change doesn't break execution of previously-compiled bytecode (any more than it was already buggy), so the worst case if backported without magic number bump is that some buggy bytecode wouldn't get the fix immediately. That's strictly better than nobody getting the fix at all in 3.12. (I'm not sure how else we can fix the issue of mangling type param names but not other names in class bases list.) And I don't see where this changes existing C API. It adds a new function, but only internal/pycore. And it changes the symtable entry struct, but again that's not part of the public API. |
Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, @JelleZijlstra, I could not cleanly backport this to
|
Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Sorry, @JelleZijlstra, I could not cleanly backport this to
|
…on#119464) Fixes python#119311. Fixes python#119395. (cherry picked from commit a9a74da)
GH-119643 is a backport of this pull request to the 3.13 branch. |
python#119464) Fixes python#119311. Fixes python#119395. (cherry picked from commit a9a74da)
GH-119644 is a backport of this pull request to the 3.12 branch. |
Fixes #119311. Fixes #119395.
There are two related bugs with name mangling in generic classes: it incorrectly gets applied to names that appear in the class's type param scope (#119311) and it leaks into code after the generic class (#119395). This PR fixes both by introducing a new mechanism where in a type param scope, only type param names are mangled.
Unfortunately, I'm not sure we can backport this to 3.12, as it changes some internal C APIs and the magic number.