8000 gh-111789: Use PyDict_GetItemRef() in Python/_warnings.c (gh-112080) · python/cpython@936c503 · GitHub
[go: up one dir, main page]

Skip to content

Commit 936c503

Browse files
gh-111789: Use PyDict_GetItemRef() in Python/_warnings.c (gh-112080)
1 parent befbad3 commit 936c503

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Python/_warnings.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,15 +425,15 @@ already_warned(PyInterpreterState *interp, PyObject *registry, PyObject *key,
425425
Py_DECREF(version_obj);
426426
}
427427
else {
428-
already_warned = PyDict_GetItemWithError(registry, key);
428+
if (PyDict_GetItemRef(registry, key, &already_warned) < 0) {
429+
return -1;
430+
}
429431
if (already_warned != NULL) {
430432
int rc = PyObject_IsTrue(already_warned);
433+
Py_DECREF(already_warned);
431434
if (rc != 0)
432435
return rc;
433436
}
434-
else if (PyErr_Occurred()) {
435-
return -1;
436-
}
437437
}
438438

439439
/* This warning wasn't found in the registry, set it. */

0 commit comments

Comments
 (0)
0