bpo-37994: Fix silencing all errors if an attribute lookup fails. (GH-15630)
Only AttributeError should be silenced.
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 9dd6712..8c16cc6 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2061,9 +2061,10 @@
_Py_IDENTIFIER(__dict__);
char *buf;
- dict = _PyObject_GetAttrId((PyObject *)self, &PyId___dict__);
+ if (_PyObject_LookupAttrId((PyObject *)self, &PyId___dict__, &dict) < 0) {
+ return NULL;
+ }
if (dict == NULL) {
- PyErr_Clear();
dict = Py_None;
Py_INCREF(dict);
}