gh-111789: Use PyDict_GetItemRef() in Python/compile.c (GH-112083)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
Serhiy Storchaka 2024-02-23 13:35:27 +02:00 committed by GitHub
parent e74cd0f910
commit acd6f41ecf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 5 deletions

View File

@ -921,11 +921,10 @@ dict_add_o(PyObject *dict, PyObject *o)
PyObject *v;
Py_ssize_t arg;
v = PyDict_GetItemWithError(dict, o);
if (!v) {
if (PyErr_Occurred()) {
if (PyDict_GetItemRef(dict, o, &v) < 0) {
return ERROR;
}
if (!v) {
arg = PyDict_GET_SIZE(dict);
v = PyLong_FromSsize_t(arg);
if (!v) {
@ -935,10 +934,10 @@ dict_add_o(PyObject *dict, PyObject *o)
Py_DECREF(v);
return ERROR;
}
Py_DECREF(v);
}
else
arg = PyLong_AsLong(v);
Py_DECREF(v);
return arg;
}