mirror of
https://github.com/python/cpython.git
synced 2025-10-25 18:54:53 +00:00
Remove redundant check for PyBytes in unicode_encode.
This commit is contained in:
parent
bd87d0862b
commit
3b9406b08a
1 changed files with 1 additions and 17 deletions
|
|
@ -7424,27 +7424,11 @@ unicode_encode(PyUnicodeObject *self, PyObject *args, PyObject *kwargs)
|
|||
static char *kwlist[] = {"encoding", "errors", 0};
|
||||
char *encoding = NULL;
|
||||
char *errors = NULL;
|
||||
PyObject *v;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ss:encode",
|
||||
kwlist, &encoding, &errors))
|
||||
return NULL;
|
||||
v = PyUnicode_AsEncodedString((PyObject *)self, encoding, errors);
|
||||
if (v == NULL)
|
||||
goto onError;
|
||||
/* XXX this check is redundant */
|
||||
if (!PyBytes_Check(v)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"encoder did not return a bytes object "
|
||||
"(type=%.400s)",
|
||||
Py_TYPE(v)->tp_name);
|
||||
Py_DECREF(v);
|
||||
return NULL;
|
||||
}
|
||||
return v;
|
||||
|
||||
onError:
|
||||
return NULL;
|
||||
return PyUnicode_AsEncodedString((PyObject *)self, encoding, errors);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(transform__doc__,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue