diff Objects/unicodeobject.c @ 66630:7851bfb1bd73

Remove redundant check for PyBytes in unicode_encode.
author Georg Brandl <georg@python.org>
date Fri, 03 Dec 2010 07:54:09 +0000
parents 7e4833764c88
children 62b61abd02b8
line wrap: on
line diff
--- a/Objects/unicodeobject.c	Fri Dec 03 07:49:09 2010 +0000
+++ b/Objects/unicodeobject.c	Fri Dec 03 07:54:09 2010 +0000
@@ -7424,27 +7424,11 @@
     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__,