diff options
author | Fred Drake <fdrake@acm.org> | 2000-10-24 19:57:45 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2000-10-24 19:57:45 (GMT) |
commit | 661ea26b3d8621ad0acc0ed2f2036ab29355f8ff (patch) | |
tree | fcfe10c4656a3e18911cd3b41b7d8c942d707786 /Objects/classobject.c | |
parent | bd6f4fba1bc66a18cc15d50ffdd33faedff5ac4c (diff) | |
download | cpython-661ea26b3d8621ad0acc0ed2f2036ab29355f8ff.zip cpython-661ea26b3d8621ad0acc0ed2f2036ab29355f8ff.tar.gz cpython-661ea26b3d8621ad0acc0ed2f2036ab29355f8ff.tar.bz2 |
Ka-Ping Yee <ping@lfw.org>:
Changes to error messages to increase consistency & clarity.
This (mostly) closes SourceForge patch #101839.
Diffstat (limited to 'Objects/classobject.c')
-rw-r--r-- | Objects/classobject.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c index c362b80..1c9cd7e 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -173,7 +173,9 @@ class_getattr(register PyClassObject *op, PyObject *name) } v = class_lookup(op, name, &class); if (v == NULL) { - PyErr_SetObject(PyExc_AttributeError, name); + PyErr_Format(PyExc_AttributeError, + "class %.50s has no attribute '%.400s'", + PyString_AS_STRING(op->cl_name), sname); return NULL; } Py_INCREF(v); @@ -285,8 +287,9 @@ class_setattr(PyClassObject *op, PyObject *name, PyObject *v) if (v == NULL) { int rv = PyDict_DelItem(op->cl_dict, name); if (rv < 0) - PyErr_SetString(PyExc_AttributeError, - "delete non-existing class attribute"); + PyErr_Format(PyExc_AttributeError, + "class %.50s has no attribute '%.400s'", + PyString_AS_STRING(op->cl_name), sname); return rv; } else @@ -578,7 +581,8 @@ instance_getattr1(register PyInstanceObject *inst, PyObject *name) } v = instance_getattr2(inst, name); if (v == NULL) { - PyErr_Format(PyExc_AttributeError,"'%.50s' instance has no attribute '%.400s'", + PyErr_Format(PyExc_AttributeError, + "%.50s instance has no attribute '%.400s'", PyString_AS_STRING(inst->in_class->cl_name), sname); } return v; @@ -642,8 +646,10 @@ instance_setattr1(PyInstanceObject *inst, PyObject *name, PyObject *v) if (v == NULL) { int rv = PyDict_DelItem(inst->in_dict, name); if (rv < 0) - PyErr_SetString(PyExc_AttributeError, - "delete non-existing instance attribute"); + PyErr_Format(PyExc_AttributeError, + "%.50s instance has no attribute '%.400s'", + PyString_AS_STRING(inst->in_class->cl_name), + PyString_AS_STRING(name)); return rv; } else |