diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-02-23 11:35:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-23 11:35:27 (GMT) |
commit | acd6f41ecf9987c21c3d238d5496b17857c05482 (patch) | |
tree | 7a2fe53d0fed7fe5b6c820648660490e321f7a78 /Python | |
parent | e74cd0f9101d06045464ac3173ab73e0b78d175e (diff) | |
download | cpython-acd6f41ecf9987c21c3d238d5496b17857c05482.zip cpython-acd6f41ecf9987c21c3d238d5496b17857c05482.tar.gz cpython-acd6f41ecf9987c21c3d238d5496b17857c05482.tar.bz2 |
gh-111789: Use PyDict_GetItemRef() in Python/compile.c (GH-112083)
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Python')
-rw-r--r-- | Python/compile.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Python/compile.c b/Python/compile.c index d857239..6b17f3b 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -921,11 +921,10 @@ dict_add_o(PyObject *dict, PyObject *o) PyObject *v; Py_ssize_t arg; - v = PyDict_GetItemWithError(dict, o); + if (PyDict_GetItemRef(dict, o, &v) < 0) { + return ERROR; + } if (!v) { - if (PyErr_Occurred()) { - return ERROR; - } 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; } |