diff options
author | Georg Brandl <georg@python.org> | 2006-11-19 08:48:30 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-11-19 08:48:30 (GMT) |
commit | 283a1353a0834d53b230b22e8db9e7b4fcd220d0 (patch) | |
tree | 38cdb53e185f70ebb4c288f28b43a2dbcc39e17f /Objects/listobject.c | |
parent | db4f255c61d11836f734cea3329145a0f370f317 (diff) | |
download | cpython-283a1353a0834d53b230b22e8db9e7b4fcd220d0.zip cpython-283a1353a0834d53b230b22e8db9e7b4fcd220d0.tar.gz cpython-283a1353a0834d53b230b22e8db9e7b4fcd220d0.tar.bz2 |
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 a1ac2cb..3083b5f 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; } } |