Make all of test_bytes pass (except pickling, which is too badly busted).

This commit is contained in:
Guido van Rossum 2007-05-04 05:00:04 +00:00
parent 6c1e6741f8
commit 4355a47903
3 changed files with 51 additions and 53 deletions

View file

@ -5634,6 +5634,12 @@ unicode_encode(PyUnicodeObject *self, PyObject *args)
if (v == NULL)
goto onError;
if (!PyBytes_Check(v)) {
if (PyString_Check(v)) {
/* Old codec, turn it into bytes */
PyObject *b = PyBytes_FromObject(v);
Py_DECREF(v);
return b;
}
PyErr_Format(PyExc_TypeError,
"encoder did not return a bytes object "
"(type=%.400s)",