]> granicus.if.org Git - python/commitdiff
Mark Hammond:
authorGuido van Rossum <guido@python.org>
Mon, 10 Apr 2000 13:03:19 +0000 (13:03 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 10 Apr 2000 13:03:19 +0000 (13:03 +0000)
In line with a similar checkin to object.c a while ago, this patch
gives a more descriptive error message for an attribute error on a
class instance.  The message now looks like:

AttributeError: 'Descriptor' instance has no attribute 'GetReturnType'

Objects/classobject.c

index 8ee13444b8da8207aeb015a5b893b651775a49d0..4fb1167489ed134ead2a22373942a820fa453d22 100644 (file)
@@ -592,7 +592,10 @@ instance_getattr1(inst, name)
        if (v == NULL) {
                v = class_lookup(inst->in_class, name, &class);
                if (v == NULL) {
-                       PyErr_SetObject(PyExc_AttributeError, name);
+                       PyErr_Format(PyExc_AttributeError,
+                                    "'%.50s' instance has no attribute '%.400s'",
+                                    PyString_AsString(inst->in_class->cl_name),
+                                    sname);
                        return NULL;
                }
        }