mirror of
https://github.com/python/cpython.git
synced 2025-07-17 00:05:20 +00:00
There should be no codecs left that return str8 intead of bytes.
(And if there are, they will now get an error when used. So fix them!)
This commit is contained in:
parent
700bd92677
commit
35d9428046
1 changed files with 1 additions and 7 deletions
|
@ -6407,19 +6407,13 @@ unicode_encode(PyUnicodeObject *self, PyObject *args)
|
||||||
char *encoding = NULL;
|
char *encoding = NULL;
|
||||||
char *errors = NULL;
|
char *errors = NULL;
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "|ss:encode", &encoding, &errors))
|
if (!PyArg_ParseTuple(args, "|ss:encode", &encoding, &errors))
|
||||||
return NULL;
|
return NULL;
|
||||||
v = PyUnicode_AsEncodedObject((PyObject *)self, encoding, errors);
|
v = PyUnicode_AsEncodedObject((PyObject *)self, encoding, errors);
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
goto onError;
|
goto onError;
|
||||||
if (!PyBytes_Check(v)) {
|
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,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"encoder did not return a bytes object "
|
"encoder did not return a bytes object "
|
||||||
"(type=%.400s)",
|
"(type=%.400s)",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue