mirror of https://github.com/python/cpython
gh-111789: Use PyDict_GetItemRef() in Modules/_struct.c (gh-112076)
This commit is contained in:
parent
b14e5df120
commit
0f00903320
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue