summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-11-03 19:19:06 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2012-11-03 19:19:06 (GMT)
commitc64bcbec4bb3cdad320184b4155cdc05c55bb10d (patch)
tree8ec1034439e34c18e6d36a09f039345b1d223c69 /Objects
parent11f3f172e7081e2de0879dff86ded51109fa4e04 (diff)
downloadcpython-c64bcbec4bb3cdad320184b4155cdc05c55bb10d.zip
cpython-c64bcbec4bb3cdad320184b4155cdc05c55bb10d.tar.gz
cpython-c64bcbec4bb3cdad320184b4155cdc05c55bb10d.tar.bz2
#8401: assigning an int to a bytearray slice (e.g. b[3:4] = 5) now raises an error.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytearrayobject.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 55b4df6..164c1cf 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -589,6 +589,12 @@ bytearray_ass_subscript(PyByteArrayObject *self, PyObject *index, PyObject *valu
needed = 0;
}
else if (values == (PyObject *)self || !PyByteArray_Check(values)) {
+ if (PyNumber_Check(values) || PyUnicode_Check(values)) {
+ PyErr_SetString(PyExc_TypeError,
+ "can assign only bytes, buffers, or iterables "
+ "of ints in range(0, 256)");
+ return -1;
+ }
/* Make a copy and call this function recursively */
int err;
values = PyByteArray_FromObject(values);