summaryrefslogtreecommitdiffstats
path: root/Objects/bytearrayobject.c
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-11-03 19:22:41 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2012-11-03 19:22:41 (GMT)
commit7376801f61330d8053c9393da813a3092f881634 (patch)
treebd6ae0bbaf488e4147acbf3d0555e5cf120083d6 /Objects/bytearrayobject.c
parent1c8bb9f4d5478c4bc7e1b9dfa291753b184c2605 (diff)
parentc64bcbec4bb3cdad320184b4155cdc05c55bb10d (diff)
downloadcpython-7376801f61330d8053c9393da813a3092f881634.zip
cpython-7376801f61330d8053c9393da813a3092f881634.tar.gz
cpython-7376801f61330d8053c9393da813a3092f881634.tar.bz2
#8401: merge with 3.2.
Diffstat (limited to 'Objects/bytearrayobject.c')
-rw-r--r--Objects/bytearrayobject.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 2bb3a29..6e95606 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);