gh-111789: Use PyDict_GetItemRef() in Modules/_threadmodule.c (gh-112077)

This commit is contained in:
Serhiy Storchaka 2023-11-27 19:46:43 +02:00 committed by GitHub
parent 0f00903320
commit ef9b2fc9b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 6 deletions

View File

@ -1115,12 +1115,10 @@ local_getattro(localobject *self, PyObject *name)
}
/* Optimization: just look in dict ourselves */
PyObject *value = PyDict_GetItemWithError(ldict, name);
if (value != NULL) {
return Py_NewRef(value);
}
if (PyErr_Occurred()) {
return NULL;
PyObject *value;
if (PyDict_GetItemRef(ldict, name, &value) != 0) {
// found or error
return value;
}
/* Fall back on generic to get __class__ and __dict__ */