mirror of
https://github.com/python/cpython.git
synced 2025-07-12 22:05:16 +00:00
SF patch #471852 (anonymous) notes that getattr(obj, name, default)
masks any exception, not just AttributeError. Fix this.
This commit is contained in:
parent
9bc9d66eb1
commit
d892357bf7
1 changed files with 3 additions and 1 deletions
|
@ -619,7 +619,9 @@ builtin_getattr(PyObject *self, PyObject *args)
|
|||
return NULL;
|
||||
}
|
||||
result = PyObject_GetAttr(v, name);
|
||||
if (result == NULL && dflt != NULL) {
|
||||
if (result == NULL && dflt != NULL &&
|
||||
PyErr_ExceptionMatches(PyExc_AttributeError))
|
||||
{
|
||||
PyErr_Clear();
|
||||
Py_INCREF(dflt);
|
||||
result = dflt;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue