diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-03-07 09:21:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-07 09:21:08 (GMT) |
commit | 72d3cc94cd8cae1925e7a14f297b06ac6184f916 (patch) | |
tree | df9d7a5a97a79f97065282dd8e5a89f57ea2e18b /Modules/timemodule.c | |
parent | 882fcede83af783a834b759e4643130dc1307ee3 (diff) | |
download | cpython-72d3cc94cd8cae1925e7a14f297b06ac6184f916.zip cpython-72d3cc94cd8cae1925e7a14f297b06ac6184f916.tar.gz cpython-72d3cc94cd8cae1925e7a14f297b06ac6184f916.tar.bz2 |
gh-116437: Use new C API PyDict_Pop() to simplify the code (GH-116438)
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r-- | Modules/timemodule.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index ed41ffd..2ec5aff 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -1928,20 +1928,20 @@ time_exec(PyObject *module) return -1; } - if (PyDict_DelItemString(dct, "clock_gettime") == -1) { - PyErr_Clear(); + if (PyDict_PopString(dct, "clock_gettime", NULL) < 0) { + return -1; } - if (PyDict_DelItemString(dct, "clock_gettime_ns") == -1) { - PyErr_Clear(); + if (PyDict_PopString(dct, "clock_gettime_ns", NULL) < 0) { + return -1; } - if (PyDict_DelItemString(dct, "clock_settime") == -1) { - PyErr_Clear(); + if (PyDict_PopString(dct, "clock_settime", NULL) < 0) { + return -1; } - if (PyDict_DelItemString(dct, "clock_settime_ns") == -1) { - PyErr_Clear(); + if (PyDict_PopString(dct, "clock_settime_ns", NULL) < 0) { + return -1; } - if (PyDict_DelItemString(dct, "clock_getres") == -1) { - PyErr_Clear(); + if (PyDict_PopString(dct, "clock_getres", NULL) < 0) { + return -1; } } #endif @@ -1951,11 +1951,11 @@ time_exec(PyObject *module) } else { PyObject* dct = PyModule_GetDict(module); - if (PyDict_DelItemString(dct, "thread_time") == -1) { - PyErr_Clear(); + if (PyDict_PopString(dct, "thread_time", NULL) < 0) { + return -1; } - if (PyDict_DelItemString(dct, "thread_time_ns") == -1) { - PyErr_Clear(); + if (PyDict_PopString(dct, "thread_time_ns", NULL) < 0) { + return -1; } } #endif |