summaryrefslogtreecommitdiff
path: root/Objects/listobject.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-11-19 08:48:30 +0000
committerGeorg Brandl <georg@python.org>2006-11-19 08:48:30 +0000
commit51aa7207f80ccbf64a29936781d83529d33ecfe1 (patch)
tree66a20bcb7f064f82ed4d9b595cbfcaad5bb71c55 /Objects/listobject.c
parent84fdd2173f8281053308801f16f6099f50adc8e1 (diff)
downloadcpython-51aa7207f80ccbf64a29936781d83529d33ecfe1.tar.gz
Patch [ 1586791 ] better error msgs for some TypeErrors
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c15
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;
}
}