Skip to content

Commit db2cb88

Browse files
authored
Remove PyDict_Contains()
1 parent 4abbc73 commit db2cb88

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

Modules/_datetimemodule.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,18 +219,16 @@ set_current_module(PyInterpreterState *interp, PyObject *mod)
219219
if (ref == NULL) {
220220
return -1;
221221
}
222-
223-
if (!PyDict_ContainsString(dict, "datetime_module_spec")) {
224-
PyObject *spec;
225-
if (PyDict_GetItemRef(PyModule_GetDict(mod), &_Py_ID(__spec__), &spec) != 1) {
226-
return -1;
227-
}
228-
if (PyDict_SetItemString(dict, "datetime_module_spec", spec) < 0) {
229-
Py_DECREF(spec);
230-
return -1;
231-
}
222+
/* A module spec remains in the dict */
223+
PyObject *spec;
224+
if (PyDict_GetItemRef(PyModule_GetDict(mod), &_Py_ID(__spec__), &spec) != 1) {
225+
return -1;
226+
}
227+
if (PyDict_SetItemString(dict, "datetime_module_spec", spec) < 0) {
232228
Py_DECREF(spec);
229+
return -1;
233230
}
231+
Py_DECREF(spec);
234232

235233
int rc = PyDict_SetItem(dict, INTERP_KEY, ref);
236234
Py_DECREF(ref);

0 commit comments

Comments
 (0)