gh-111789: Use PyDict_GetItemRef() in Objects/ (GH-111827)

This commit is contained in:
Serhiy Storchaka 2023-11-14 11:25:39 +02:00 committed by GitHub
parent e31d65e0b7
commit 18203a6bc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 76 additions and 120 deletions

View file

@ -204,12 +204,7 @@ int
PyMapping_GetOptionalItem(PyObject *obj, PyObject *key, PyObject **result)
{
if (PyDict_CheckExact(obj)) {
*result = PyDict_GetItemWithError(obj, key); /* borrowed */
if (*result) {
Py_INCREF(*result);
return 1;
}
return PyErr_Occurred() ? -1 : 0;
return PyDict_GetItemRef(obj, key, result);
}
*result = PyObject_GetItem(obj, key);