-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-125017: Fix crash on premature access to classmethod/staticmethod annotations #125636
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
…ethod annotations
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.
LGTM, thanks!
Is there any backport needed here? I'm not sure if the original PR made it in 3.13 |
No, this is a PEP 649 change and is only on main. |
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.
Thanks Jelle!
A
8000
Heads-up: this appears to have caused some refleak buildbot failures, see for example https://buildbot.python.org/#/builders/1613/builds/116 |
Actually, on a second look, this part is technically unsafe: else {
Py_DECREF(dict);
return PyDict_SetItem(dict, name, value);
} If the dictionary's reference count is 1, then this will result in a use-after-free. Though, I guess that's never possible because the dictionary will be stored on the instance as well. In hindsight, there should have either been an assertion (or just not do it in the first place), but oh well. |
…ethod annotations (python#125636)
cls.__dict__['__new__'].__annotations__
#125017