Skip to content

Commit

Permalink
pythongh-111789: Use PyDict_GetItemRef() in Python/_warnings.c (pytho…
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka authored and Glyphack committed Jan 27, 2024
1 parent d3f0691 commit 3133fe0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Python/_warnings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit 3133fe0

Please sign in to comment.