diff options
| author | Guido van Rossum <guido@python.org> | 2007-05-04 05:00:04 +0000 |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 2007-05-04 05:00:04 +0000 |
| commit | 4355a47903f3242222b5807c71ec3dda4a8c8d5c (patch) | |
| tree | 958b5582fa088b1595b9625371c11344bfa6d14a /Objects/unicodeobject.c | |
| parent | 6c1e6741f8e3f44fbf7dc05e3ec79a1290c63c11 (diff) | |
| download | cpython-git-4355a47903f3242222b5807c71ec3dda4a8c8d5c.tar.gz | |
Make all of test_bytes pass (except pickling, which is too badly busted).
Diffstat (limited to 'Objects/unicodeobject.c')
| -rw-r--r-- | Objects/unicodeobject.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 26d6fc64ee..d4a17ce43b 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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)", |
