https://github.com/python/cpython/commit/acd6f41ecf9987c21c3d238d5496b17857c05482 commit: acd6f41ecf9987c21c3d238d5496b17857c05482 branch: main author: Serhiy Storchaka <[email protected]> committer: ambv <[email protected]> date: 2024-02-23T12:35:27+01:00 summary:
gh-111789: Use PyDict_GetItemRef() in Python/compile.c (GH-112083) Co-authored-by: Ćukasz Langa <[email protected]> files: M Python/compile.c diff --git a/Python/compile.c b/Python/compile.c index d857239690e7b5..6b17f3bcaf2264 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; } _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
