Mercurial > cpython-lru_cache-weakref
diff Objects/bytesobject.c @ 42457:080f2aa18015
Change PyUnicode_FromString[AndSize] to expect UTF-8.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Sun, 05 Aug 2007 20:26:11 +0000 |
| parents | c8b850b5a066 |
| children | 96098abc8f8f |
line wrap: on
line diff
--- a/Objects/bytesobject.c Sun Aug 05 15:39:16 2007 +0000 +++ b/Objects/bytesobject.c Sun Aug 05 20:26:11 2007 +0000 @@ -2724,11 +2724,13 @@ 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 = {
