Skip to content

Commit ac7f87c

Browse files
serhiy-storchakaaisk
authored andcommitted
pythongh-111789: Use PyDict_GetItemRef() in Modules/_threadmodule.c (pythongh-112077)
1 parent 5cf2048 commit ac7f87c

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Modules/_threadmodule.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,12 +1115,10 @@ local_getattro(localobject *self, PyObject *name)
11151115
}
11161116

11171117
/* Optimization: just look in dict ourselves */
1118-
PyObject *value = PyDict_GetItemWithError(ldict, name);
1119-
if (value != NULL) {
1120-
return Py_NewRef(value);
1121-
}
1122-
if (PyErr_Occurred()) {
1123-
return NULL;
1118+
PyObject *value;
1119+
if (PyDict_GetItemRef(ldict, name, &value) != 0) {
1120+
// found or error
1121+
return value;
11241122
}
11251123

11261124
/* Fall back on generic to get __class__ and __dict__ */

0 commit comments

Comments
 (0)