gh-111789: Use PyDict_GetItemRef() in Modules/_struct.c (gh-112076)

This commit is contained in:
Serhiy Storchaka 2023-11-27 19:41:47 +02:00 committed by GitHub
parent b14e5df120
commit 0f00903320
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 6 deletions

View File

@ -2257,14 +2257,13 @@ cache_struct_converter(PyObject *module, PyObject *fmt, PyStructObject **ptr)
return 1;
}
s_object = PyDict_GetItemWithError(state->cache, fmt);
if (s_object != NULL) {
*ptr = (PyStructObject *)Py_NewRef(s_object);
return Py_CLEANUP_SUPPORTED;
}
else if (PyErr_Occurred()) {
if (PyDict_GetItemRef(state->cache, fmt, &s_object) < 0) {
return 0;
}
if (s_object != NULL) {
*ptr = (PyStructObject *)s_object;
return Py_CLEANUP_SUPPORTED;
}
s_object = PyObject_CallOneArg(state->PyStructType, fmt);
if (s_object != NULL) {