mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #22077: Improve index error messages for bytearrays, bytes, lists, and
tuples by adding 'or slices'. Added ', not <typename' for bytearrays. Original patch by Claudiu Popa.
This commit is contained in:
parent
7f9cc9359b
commit
ffff1440d1
8 changed files with 45 additions and 6 deletions
|
@ -445,7 +445,9 @@ bytearray_subscript(PyByteArrayObject *self, PyObject *index)
|
|||
}
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "bytearray indices must be integers");
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"bytearray indices must be integers or slices, not %.200s",
|
||||
Py_TYPE(index)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -650,7 +652,9 @@ bytearray_ass_subscript(PyByteArrayObject *self, PyObject *index, PyObject *valu
|
|||
}
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "bytearray indices must be integer");
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"bytearray indices must be integers or slices, not %.200s",
|
||||
Py_TYPE(index)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue