bpo-37994: Fix silencing all errors if an attribute lookup fails. (GH-15630)

Only AttributeError should be silenced.
This commit is contained in:
Serhiy Storchaka 2019-09-01 12:03:39 +03:00 committed by GitHub
parent f02ea6225b
commit 41c57b3353
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 134 additions and 127 deletions

View file

@ -163,10 +163,10 @@ weakref_repr(PyWeakReference *self)
if (PyWeakref_GET_OBJECT(self) == Py_None)
return PyUnicode_FromFormat("<weakref at %p; dead>", self);
name = _PyObject_GetAttrId(PyWeakref_GET_OBJECT(self), &PyId___name__);
if (_PyObject_LookupAttrId(PyWeakref_GET_OBJECT(self), &PyId___name__, &name) < 0) {
return NULL;
}
if (name == NULL || !PyUnicode_Check(name)) {
if (name == NULL)
PyErr_Clear();
repr = PyUnicode_FromFormat(
"<weakref at %p; to '%s' at %p>",
self,