[Python-checkins] r86959 - python/branches/py3k/Objects/unicodeobject.c

georg.brandl python-checkins at python.org
Fri Dec 3 08:54:09 CET 2010


Author: georg.brandl
Date: Fri Dec  3 08:54:09 2010
New Revision: 86959

Log:
Remove redundant check for PyBytes in unicode_encode.

Modified:
   python/branches/py3k/Objects/unicodeobject.c

Modified: python/branches/py3k/Objects/unicodeobject.c
==============================================================================
--- python/branches/py3k/Objects/unicodeobject.c	(original)
+++ python/branches/py3k/Objects/unicodeobject.c	Fri Dec  3 08:54:09 2010
@@ -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__,


More information about the Python-checkins mailing list