diff -r 3ecddf168f1f Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c Tue Nov 29 00:53:09 2011 +0100 +++ b/Objects/bytearrayobject.c Wed Nov 30 00:53:40 2011 +0100 @@ -2732,20 +2732,7 @@ static PyObject * bytearray_reduce(PyByteArrayObject *self) { - PyObject *latin1, *dict; - if (self->ob_bytes) -#ifdef Py_USING_UNICODE - latin1 = PyUnicode_DecodeLatin1(self->ob_bytes, - Py_SIZE(self), NULL); -#else - latin1 = PyString_FromStringAndSize(self->ob_bytes, Py_SIZE(self)); -#endif - else -#ifdef Py_USING_UNICODE - latin1 = PyUnicode_FromString(""); -#else - latin1 = PyString_FromString(""); -#endif + PyObject *dict; dict = PyObject_GetAttrString((PyObject *)self, "__dict__"); if (dict == NULL) { @@ -2754,7 +2741,11 @@ Py_INCREF(dict); } - return Py_BuildValue("(O(Ns)N)", Py_TYPE(self), latin1, "latin-1", dict); + if(self->ob_bytes) { + return Py_BuildValue("(O(s#)N)", Py_TYPE(self), self->ob_bytes, Py_SIZE(self), dict); + } else { + return Py_BuildValue("(O()N)", Py_TYPE(self), dict); + } } PyDoc_STRVAR(sizeof_doc,