Change PyUnicode_FromString[AndSize] to expect UTF-8.

This commit is contained in:
Martin v. Löwis 2007-08-05 20:26:11 +00:00
parent 64ce5052e1
commit 9c121069d3
3 changed files with 25 additions and 20 deletions

View file

@ -2724,11 +2724,13 @@ PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
static PyObject *
bytes_reduce(PyBytesObject *self)
{
return Py_BuildValue("(O(s#s))",
Py_Type(self),
self->ob_bytes == NULL ? "" : self->ob_bytes,
Py_Size(self),
"latin-1");
PyObject *latin1;
if (self->ob_bytes)
latin1 = PyUnicode_DecodeLatin1(self->ob_bytes,
Py_Size(self), NULL);
else
latin1 = PyUnicode_FromString("");
return Py_BuildValue("(O(Ns))", Py_Type(self), latin1, "latin-1");
}
static PySequenceMethods bytes_as_sequence = {