gh-106033: Get rid of new occurrences of PyDict_GetItem and PyObject_HasAttr (GH-106034)

These functions are broken by design because they discard any exceptions raised
inside, including MemoryError and KeyboardInterrupt.  They should not be
used in new code.
This commit is contained in:
Serhiy Storchaka 2023-06-23 20:10:32 +03:00 committed by GitHub
parent 41ad4dfc04
commit 1d33d53780
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 34 deletions

View file

@ -9,7 +9,7 @@ get_code_extra_index(PyInterpreterState* interp) {
PyObject *interp_dict = PyInterpreterState_GetDict(interp); // borrowed
assert(interp_dict); // real users would handle missing dict... somehow
PyObject *index_obj = PyDict_GetItemString(interp_dict, key); // borrowed
PyObject *index_obj = _PyDict_GetItemStringWithError(interp_dict, key); // borrowed
Py_ssize_t index = 0;
if (!index_obj) {
if (PyErr_Occurred()) {