Skip to content

Commit

Permalink
pythongh-111789: Use PyDict_GetItemRef() in Modules/_threadmodule.c (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka authored and aisk committed Feb 11, 2024
1 parent 5cf2048 commit ac7f87c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Modules/_threadmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */
Expand Down

0 comments on commit ac7f87c

Please sign in to comment.