summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-11-27 17:58:43 (GMT)
committerGitHub <noreply@github.com>2023-11-27 17:58:43 (GMT)
commit936c503a442ee062c837e334f237796554c792ff (patch)
tree8632e1e7fe8f0a1e2757f58c6ec18c2ed33d21a9
parentbefbad3663a48a8de2e1263afe18ec9fa47dfc6d (diff)
downloadcpython-936c503a442ee062c837e334f237796554c792ff.zip
cpython-936c503a442ee062c837e334f237796554c792ff.tar.gz
cpython-936c503a442ee062c837e334f237796554c792ff.tar.bz2
gh-111789: Use PyDict_GetItemRef() in Python/_warnings.c (gh-112080)
-rw-r--r--Python/_warnings.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 4b7fb88..d476503 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -425,15 +425,15 @@ already_warned(PyInterpreterState *interp, PyObject *registry, PyObject *key,
Py_DECREF(version_obj);
}
else {
- already_warned = PyDict_GetItemWithError(registry, key);
+ if (PyDict_GetItemRef(registry, key, &already_warned) < 0) {
+ return -1;
+ }
if (already_warned != NULL) {
int rc = PyObject_IsTrue(already_warned);
+ Py_DECREF(already_warned);
if (rc != 0)
return rc;
}
- else if (PyErr_Occurred()) {
- return -1;
- }
}
/* This warning wasn't found in the registry, set it. */