gh-125017: Fix crash on premature access to classmethod/staticmethod annotations#125636
gh-125017: Fix crash on premature access to classmethod/staticmethod annotations#125636JelleZijlstra merged 1 commit into
Conversation
…ethod annotations
ZeroIntensity
left a comment
There was a problem hiding this comment.
LGTM, thanks!
Sorry, something went wrong.
|
Is there any backport needed here? I'm not sure if the original PR made it in 3.13 |
Sorry, something went wrong.
|
No, this is a PEP 649 change and is only on main. |
Sorry, something went wrong.
AA-Turner
left a comment
There was a problem hiding this comment.
Thanks Jelle!
A
Sorry, something went wrong.
|
Heads-up: this appears to have caused some refleak buildbot failures, see for example https://buildbot.python.org/#/builders/1613/builds/116 |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
…ethod annotations (python#125636)
cls.__dict__['__new__'].__annotations__#125017