Minor bugs in the __index__ code (PEP 357), with tests.

This commit is contained in:
Armin Rigo 2006-03-30 14:04:02 +00:00
parent 4ef3a23a35
commit 314861c568
3 changed files with 100 additions and 132 deletions

View file

@ -942,8 +942,9 @@ PyNumber_Index(PyObject *item)
value = nb->nb_index(item);
}
else {
PyErr_SetString(PyExc_IndexError,
"object cannot be interpreted as an index");
PyErr_Format(PyExc_TypeError,
"'%.200s' object cannot be interpreted "
"as an index", item->ob_type->tp_name);
}
return value;
}