diff options
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); |