Skip to content

Commit

Permalink
pythongh-111789: Use PyDict_GetItemRef() in Modules/_struct.c (python…
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka authored and aisk committed Feb 11, 2024
1 parent 30655fa commit 5cf2048
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Modules/_struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -2257,14 +2257,13 @@ cache_struct_converter(PyObject *module, PyObject *fmt, PyStructObject **ptr)
return 1;
}

s_object = PyDict_GetItemWithError(state->cache, fmt);
if (PyDict_GetItemRef(state->cache, fmt, &s_object) < 0) {
return 0;
}
if (s_object != NULL) {
*ptr = (PyStructObject *)Py_NewRef(s_object);
*ptr = (PyStructObject *)s_object;
return Py_CLEANUP_SUPPORTED;
}
else if (PyErr_Occurred()) {
return 0;
}

s_object = PyObject_CallOneArg(state->PyStructType, fmt);
if (s_object != NULL) {
Expand Down

0 comments on commit 5cf2048

Please sign in to comment.