summaryrefslogtreecommitdiffstats
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2007-08-05 20:26:11 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2007-08-05 20:26:11 (GMT)
commit9c121069d3a61868f4586ad2ba2e5435a82af061 (patch)
tree2b855fe92ed298ec849c14a4f01a9c0402a6fff7 /Objects/bytesobject.c
parent64ce5052e1c2495bcbc78f732e8ece2f4c8375ac (diff)
downloadcpython-9c121069d3a61868f4586ad2ba2e5435a82af061.zip
cpython-9c121069d3a61868f4586ad2ba2e5435a82af061.tar.gz
cpython-9c121069d3a61868f4586ad2ba2e5435a82af061.tar.bz2
Change PyUnicode_FromString[AndSize] to expect UTF-8.
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r--Objects/bytesobject.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 25f7763..47ee8a4 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -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 = {