diff options
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/Objects/object.c b/Objects/object.c index 59d39605d2..73c89417eb 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -1068,7 +1068,8 @@ PyObject_Hash(PyObject *v) return _Py_HashPointer(v); /* Use address as hash value */ } /* If there's a cmp but no hash defined, the object can't be hashed */ - PyErr_SetString(PyExc_TypeError, "unhashable type"); + PyErr_Format(PyExc_TypeError, "unhashable type: '%.200s'", + v->ob_type->tp_name); return -1; } @@ -1133,8 +1134,9 @@ PyObject_GetAttr(PyObject *v, PyObject *name) else #endif { - PyErr_SetString(PyExc_TypeError, - "attribute name must be string"); + PyErr_Format(PyExc_TypeError, + "attribute name must be string, not '%.200s'", + name->ob_type->tp_name); return NULL; } } @@ -1179,8 +1181,9 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value) else #endif { - PyErr_SetString(PyExc_TypeError, - "attribute name must be string"); + PyErr_Format(PyExc_TypeError, + "attribute name must be string, not '%.200s'", + name->ob_type->tp_name); return -1; } } @@ -1277,8 +1280,9 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name) else #endif { - PyErr_SetString(PyExc_TypeError, - "attribute name must be string"); + PyErr_Format(PyExc_TypeError, + "attribute name must be string, not '%.200s'", + name->ob_type->tp_name); return NULL; } } @@ -1399,8 +1403,9 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value) else #endif { - PyErr_SetString(PyExc_TypeError, - "attribute name must be string"); + PyErr_Format(PyExc_TypeError, + "attribute name must be string, not '%.200s'", + name->ob_type->tp_name); return -1; } } @@ -1450,7 +1455,7 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value) if (descr == NULL) { PyErr_Format(PyExc_AttributeError, - "'%.50s' object has no attribute '%.400s'", + "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AS_STRING(name)); goto done; } @@ -1773,8 +1778,9 @@ PyObject_Dir(PyObject *arg) assert(result); if (!PyList_Check(result)) { - PyErr_SetString(PyExc_TypeError, - "Expected keys() to be a list."); + PyErr_Format(PyExc_TypeError, + "Expected keys() to be a list, not '%.200s'", + result->ob_type->tp_name); goto error; } if (PyList_Sort(result) != 0) |