diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-01-25 08:49:40 (GMT) |
---|---|---|
committer | INADA Naoki <methane@users.noreply.github.com> | 2018-01-25 08:49:40 (GMT) |
commit | f320be77ffb73e3b9e7fc98c37b8df3975d84b40 (patch) | |
tree | 552338f0200938249233fa4aa7b00add61965337 /Modules/arraymodule.c | |
parent | 2b822a0bb1de2612c85d8f75e3ce89eda2ac9f68 (diff) | |
download | cpython-f320be77ffb73e3b9e7fc98c37b8df3975d84b40.zip cpython-f320be77ffb73e3b9e7fc98c37b8df3975d84b40.tar.gz cpython-f320be77ffb73e3b9e7fc98c37b8df3975d84b40.tar.bz2 |
bpo-32571: Avoid raising unneeded AttributeError and silencing it in C code (GH-5222)
Add two new private APIs: _PyObject_LookupAttr() and _PyObject_LookupAttrId()
Diffstat (limited to 'Modules/arraymodule.c')
-rw-r--r-- | Modules/arraymodule.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 8c3f0a1..900c374 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -2203,11 +2203,10 @@ array_array___reduce_ex__(arrayobject *self, PyObject *value) if (protocol == -1 && PyErr_Occurred()) return NULL; - dict = _PyObject_GetAttrId((PyObject *)self, &PyId___dict__); + if (_PyObject_LookupAttrId((PyObject *)self, &PyId___dict__, &dict) < 0) { + return NULL; + } if (dict == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return NULL; - PyErr_Clear(); dict = Py_None; Py_INCREF(dict); } |