gh-94673: Ensure Builtin Static Types are Readied Properly (gh-103940)

There were cases where we do unnecessary work for builtin static types. This also simplifies some work necessary for a per-interpreter GIL.
This commit is contained in:
Eric Snow 2023-04-27 16:19:43 -06:00 committed by GitHub
parent 56c7176d1d
commit d2e2e53f73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 89 additions and 169 deletions

View file

@ -890,7 +890,7 @@ PyObject_Hash(PyObject *v)
* an explicit call to PyType_Ready, we implicitly call
* PyType_Ready here and then check the tp_hash slot again
*/
if (tp->tp_dict == NULL) {
if (!_PyType_IsReady(tp)) {
if (PyType_Ready(tp) < 0)
return -1;
if (tp->tp_hash != NULL)
@ -1385,7 +1385,7 @@ _PyObject_GenericGetAttrWithDict(PyObject *obj, PyObject *name,
}
Py_INCREF(name);
if (tp->tp_dict == NULL) {
if (!_PyType_IsReady(tp)) {
if (PyType_Ready(tp) < 0)
goto done;
}
@ -1507,8 +1507,9 @@ _PyObject_GenericSetAttrWithDict(PyObject *obj, PyObject *name,
return -1;
}
if (tp->tp_dict == NULL && PyType_Ready(tp) < 0)
if (!_PyType_IsReady(tp) && PyType_Ready(tp) < 0) {
return -1;
}
Py_INCREF(name);
Py_INCREF(tp);