summaryrefslogtreecommitdiffstats
path: root/Objects/bytearrayobject.c
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-11-03 19:24:47 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2012-11-03 19:24:47 (GMT)
commit212843b29f573f56c16940b0600b907847fc11f7 (patch)
treee4530d649b0ade596291528b8723572011d386ad /Objects/bytearrayobject.c
parent1a5f3ec9a97311dc6d956aea4ec44a06db0d112a (diff)
parentc64bcbec4bb3cdad320184b4155cdc05c55bb10d (diff)
downloadcpython-212843b29f573f56c16940b0600b907847fc11f7.zip
cpython-212843b29f573f56c16940b0600b907847fc11f7.tar.gz
cpython-212843b29f573f56c16940b0600b907847fc11f7.tar.bz2
#8401: merge with 3.3.
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 a98ecdd..88a0140 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);