diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-09-17 11:23:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-17 11:23:31 (GMT) |
commit | add16f1a5e4013f97d33cc677dc008e8199f5b11 (patch) | |
tree | 2c187adbae2766f942e35780950a526dfe84ff48 /Python/suggestions.c | |
parent | e57ecf6bbc59f999d27b125ea51b042c24a07bd9 (diff) | |
download | cpython-add16f1a5e4013f97d33cc677dc008e8199f5b11.zip cpython-add16f1a5e4013f97d33cc677dc008e8199f5b11.tar.gz cpython-add16f1a5e4013f97d33cc677dc008e8199f5b11.tar.bz2 |
gh-108511: Add C API functions which do not silently ignore errors (GH-109025)
Add the following functions:
* PyObject_HasAttrWithError()
* PyObject_HasAttrStringWithError()
* PyMapping_HasKeyWithError()
* PyMapping_HasKeyStringWithError()
Diffstat (limited to 'Python/suggestions.c')
-rw-r--r-- | Python/suggestions.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Python/suggestions.c b/Python/suggestions.c index 9247da4..1ad359b 100644 --- a/Python/suggestions.c +++ b/Python/suggestions.c @@ -245,14 +245,12 @@ get_suggestions_for_name_error(PyObject* name, PyFrameObject* frame) goto error; } - PyObject *value; - res = PyObject_GetOptionalAttr(self, name, &value); + res = PyObject_HasAttrWithError(self, name); Py_DECREF(locals); if (res < 0) { goto error; } - if (value) { - Py_DECREF(value); + if (res) { Py_DECREF(dir); return PyUnicode_FromFormat("self.%U", name); } |