Kaydet (Commit) d892357b authored tarafından Guido van Rossum's avatar Guido van Rossum

SF patch #471852 (anonymous) notes that getattr(obj, name, default)

masks any exception, not just AttributeError.  Fix this.
üst 9bc9d66e
...@@ -619,7 +619,9 @@ builtin_getattr(PyObject *self, PyObject *args) ...@@ -619,7 +619,9 @@ builtin_getattr(PyObject *self, PyObject *args)
return NULL; return NULL;
} }
result = PyObject_GetAttr(v, name); result = PyObject_GetAttr(v, name);
if (result == NULL && dflt != NULL) { if (result == NULL && dflt != NULL &&
PyErr_ExceptionMatches(PyExc_AttributeError))
{
PyErr_Clear(); PyErr_Clear();
Py_INCREF(dflt); Py_INCREF(dflt);
result = dflt; result = dflt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment