mirror of
https://github.com/python/cpython.git
synced 2025-08-28 04:35:02 +00:00
Make all of test_bytes pass (except pickling, which is too badly busted).
This commit is contained in:
parent
6c1e6741f8
commit
4355a47903
3 changed files with 51 additions and 53 deletions
|
@ -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)",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue