]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-111789: Use PyDict_GetItemRef() in Modules/_threadmodule.c (gh-112077)
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 27 Nov 2023 17:46:43 +0000 (19:46 +0200)
committerGitHub <noreply@github.com>
Mon, 27 Nov 2023 17:46:43 +0000 (18:46 +0100)
Modules/_threadmodule.c

index c608789b5fbd5c89609916636a69e0bb7ac654e6..afcf646e3bc19e1061e8dbb3f68976d9c669c3af 100644 (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__ */