mirror of https://github.com/python/cpython
gh-111789: Use PyDict_GetItemRef() in Modules/_zoneinfo.c (GH-112078)
This commit is contained in:
parent
be5e65fdf6
commit
183b97bb9d
|
@ -853,28 +853,19 @@ load_timedelta(zoneinfo_state *state, long seconds)
|
||||||
if (pyoffset == NULL) {
|
if (pyoffset == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
rv = PyDict_GetItemWithError(state->TIMEDELTA_CACHE, pyoffset);
|
if (PyDict_GetItemRef(state->TIMEDELTA_CACHE, pyoffset, &rv) == 0) {
|
||||||
if (rv == NULL) {
|
|
||||||
if (PyErr_Occurred()) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
PyObject *tmp = PyDateTimeAPI->Delta_FromDelta(
|
PyObject *tmp = PyDateTimeAPI->Delta_FromDelta(
|
||||||
0, seconds, 0, 1, PyDateTimeAPI->DeltaType);
|
0, seconds, 0, 1, PyDateTimeAPI->DeltaType);
|
||||||
|
|
||||||
if (tmp == NULL) {
|
if (tmp != NULL) {
|
||||||
goto error;
|
rv = PyDict_SetDefault(state->TIMEDELTA_CACHE, pyoffset, tmp);
|
||||||
|
Py_XINCREF(rv);
|
||||||
|
Py_DECREF(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = PyDict_SetDefault(state->TIMEDELTA_CACHE, pyoffset, tmp);
|
|
||||||
Py_DECREF(tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_XINCREF(rv);
|
|
||||||
Py_DECREF(pyoffset);
|
Py_DECREF(pyoffset);
|
||||||
return rv;
|
return rv;
|
||||||
error:
|
|
||||||
Py_DECREF(pyoffset);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Constructor for _ttinfo object - this starts by initializing the _ttinfo
|
/* Constructor for _ttinfo object - this starts by initializing the _ttinfo
|
||||||
|
|
Loading…
Reference in New Issue