]> granicus.if.org Git - python/commitdiff
SF patch #471852 (anonymous) notes that getattr(obj, name, default)
authorGuido van Rossum <guido@python.org>
Tue, 16 Oct 2001 21:31:32 +0000 (21:31 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 16 Oct 2001 21:31:32 +0000 (21:31 +0000)
masks any exception, not just AttributeError.  Fix this.

Python/bltinmodule.c

index 8390b7b80b982d2a5a400baf7a98928df3c4c880..144a62f920c99f640c5bd949e8552bfee3196e01 100644 (file)
@@ -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;