diff Python/bltinmodule.c @ 20471:bbdc0abfbb13 legacy-trunk

SF patch #471852 (anonymous) notes that getattr(obj, name, default) masks any exception, not just AttributeError. Fix this.
author Guido van Rossum <guido@python.org>
date Tue, 16 Oct 2001 21:31:32 +0000
parents aa681345bfab
children edd9d0b3c47e
line wrap: on
line diff
--- a/Python/bltinmodule.c	Tue Oct 16 21:23:58 2001 +0000
+++ b/Python/bltinmodule.c	Tue Oct 16 21:31:32 2001 +0000
@@ -619,7 +619,9 @@
 		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;