diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2012-11-03 19:24:47 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2012-11-03 19:24:47 (GMT) |
commit | 212843b29f573f56c16940b0600b907847fc11f7 (patch) | |
tree | e4530d649b0ade596291528b8723572011d386ad /Objects/bytearrayobject.c | |
parent | 1a5f3ec9a97311dc6d956aea4ec44a06db0d112a (diff) | |
parent | c64bcbec4bb3cdad320184b4155cdc05c55bb10d (diff) | |
download | cpython-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.c | 6 |
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); |