Make all the multibyte codec tests pass.
Changes to io.py, necessary to make this work:
- Redid io.StringIO as a TextIOWrapper on top of a BytesIO instance.
- Got rid of _MemoryIOMixin, folding it into BytesIO instead.
- The read() functions that take -1 to mean "eveything" now also take None.
- Added readline() support to BufferedIOBase. :-(
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
index b26d38e..dae82b7 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -138,6 +138,11 @@
 {
 	PyObject *cb;
 
+        if (PyUnicode_Check(value)) {
+		value = _PyUnicode_AsDefaultEncodedString(value, NULL);
+		if (value == NULL)
+			return -1;
+	}
 	if (!PyString_Check(value)) {
 		PyErr_SetString(PyExc_TypeError, "errors must be a string");
 		return -1;
@@ -322,11 +327,11 @@
 			goto errorexit;
 	}
 
-        assert(PyString_Check(retstr));
-	retstrsize = PyString_GET_SIZE(retstr);
+        assert(PyBytes_Check(retstr));
+	retstrsize = PyBytes_GET_SIZE(retstr);
 	REQUIRE_ENCODEBUFFER(buf, retstrsize);
 
-	memcpy(buf->outbuf, PyString_AS_STRING(retstr), retstrsize);
+	memcpy(buf->outbuf, PyBytes_AS_STRING(retstr), retstrsize);
 	buf->outbuf += retstrsize;
 
 	newpos = PyInt_AsSsize_t(PyTuple_GET_ITEM(retobj, 1));
@@ -1224,10 +1229,18 @@
 		if (cres == NULL)
 			goto errorexit;
 
+		if (PyString_Check(cres)) {
+			PyObject *cres2 = PyBytes_FromObject(cres);
+			if (cres2 == NULL)
+				return NULL;
+			Py_DECREF(cres);
+			cres = cres2;
+		}
+
 		if (!PyBytes_Check(cres)) {
 			PyErr_Format(PyExc_TypeError,
                                      "stream function returned a "
-                                     "non-string object (%.100s)",
+                                     "non-bytes object (%.100s)",
                                      cres->ob_type->tp_name);
 			goto errorexit;
 		}
@@ -1596,8 +1609,8 @@
 	if (pwrt == NULL)
 		return NULL;
 
-        assert(PyString_Check(pwrt));
-	if (PyString_Size(pwrt) > 0) {
+        assert(PyBytes_Check(pwrt));
+	if (PyBytes_Size(pwrt) > 0) {
 		PyObject *wr;
 		wr = PyObject_CallMethod(self->stream, "write", "O", pwrt);
 		if (wr == NULL) {