diff options
author | Georg Brandl <georg@python.org> | 2006-11-19 08:48:30 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-11-19 08:48:30 +0000 |
commit | 51aa7207f80ccbf64a29936781d83529d33ecfe1 (patch) | |
tree | 66a20bcb7f064f82ed4d9b595cbfcaad5bb71c55 /Objects/listobject.c | |
parent | 84fdd2173f8281053308801f16f6099f50adc8e1 (diff) | |
download | cpython-51aa7207f80ccbf64a29936781d83529d33ecfe1.tar.gz |
Patch [ 1586791 ] better error msgs for some TypeErrors
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r-- | Objects/listobject.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c index a1ac2cba10..3083b5f3e0 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -946,9 +946,10 @@ islt(PyObject *x, PyObject *y, PyObject *compare) if (res == NULL) return -1; if (!PyInt_Check(res)) { + PyErr_Format(PyExc_TypeError, + "comparison function must return int, not %.200s", + res->ob_type->tp_name); Py_DECREF(res); - PyErr_SetString(PyExc_TypeError, - "comparison function must return int"); return -1; } i = PyInt_AsLong(res); @@ -2491,8 +2492,9 @@ list_subscript(PyListObject* self, PyObject* item) } } else { - PyErr_SetString(PyExc_TypeError, - "list indices must be integers"); + PyErr_Format(PyExc_TypeError, + "list indices must be integers, not %.200s", + item->ob_type->tp_name); return NULL; } } @@ -2635,8 +2637,9 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value) } } else { - PyErr_SetString(PyExc_TypeError, - "list indices must be integers"); + PyErr_Format(PyExc_TypeError, + "list indices must be integers, not %.200s", + item->ob_type->tp_name); return -1; } } |