mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-37994: Fix silencing all errors if an attribute lookup fails. (GH-15630)
Only AttributeError should be silenced.
This commit is contained in:
parent
f02ea6225b
commit
41c57b3353
14 changed files with 134 additions and 127 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue