From: Serhiy Storchaka Date: Mon, 27 Nov 2023 17:46:43 +0000 (+0200) Subject: gh-111789: Use PyDict_GetItemRef() in Modules/_threadmodule.c (gh-112077) X-Git-Tag: v3.13.0a3~625 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ef9b2fc9b0378aee87328fadce73b3fefb6aca4a;p=thirdparty%2FPython%2Fcpython.git gh-111789: Use PyDict_GetItemRef() in Modules/_threadmodule.c (gh-112077) --- diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index c608789b5fbd..afcf646e3bc1 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -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__ */