summaryrefslogtreecommitdiffstats
path: root/Objects/bytearrayobject.c
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2014-08-02 05:30:37 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2014-08-02 05:30:37 (GMT)
commitffff1440d118cae189a6c2baf595dda52cdc7c3a (patch)
treee1664353a0276044933c16879fa59e7521a6044e /Objects/bytearrayobject.c
parent7f9cc9359bdbcc877b2a6f976c8e8bdbc714ce90 (diff)
downloadcpython-ffff1440d118cae189a6c2baf595dda52cdc7c3a.zip
cpython-ffff1440d118cae189a6c2baf595dda52cdc7c3a.tar.gz
cpython-ffff1440d118cae189a6c2baf595dda52cdc7c3a.tar.bz2
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.
Diffstat (limited to 'Objects/bytearrayobject.c')
-rw-r--r--Objects/bytearrayobject.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 242b3b2..f6f370d 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -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;
}