diff -r f3f42a8c3e26 Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c Wed Nov 13 12:11:36 2013 +0100 +++ b/Objects/bytearrayobject.c Wed Nov 13 13:15:47 2013 +0100 @@ -482,8 +482,16 @@ bytearray_setslice_linear(PyByteArrayObj } /* XXX(nnorwitz): need to verify this can't overflow! */ if (PyByteArray_Resize( - (PyObject *)self, Py_SIZE(self) + growth) < 0) + (PyObject *)self, Py_SIZE(self) + growth) < 0) { + if (growth < 0) { + if (lo == 0) + self->ob_start += growth; + else + memmove(buf + hi, buf + lo + bytes_len, + Py_SIZE(self) - hi); + } return -1; + } buf = PyByteArray_AS_STRING(self); if (growth > 0) { /* Make the place for the additional bytes */