mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
Minor bugs in the __index__ code (PEP 357), with tests.
This commit is contained in:
parent
4ef3a23a35
commit
314861c568
3 changed files with 100 additions and 132 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue