]> granicus.if.org Git - python/commitdiff
Allow encoding names to be unicode strings.
authorGuido van Rossum <guido@python.org>
Thu, 17 May 2007 18:56:39 +0000 (18:56 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 17 May 2007 18:56:39 +0000 (18:56 +0000)
Modules/cjkcodecs/cjkcodecs.h

index 71c54f093fc96a24ef11f8fb3fa57453d5e64c56..c79b304a03831d97997068afb02f9d39fed1767d 100644 (file)
@@ -261,6 +261,11 @@ getcodec(PyObject *self, PyObject *encoding)
        const MultibyteCodec *codec;
        const char *enc;
 
+        if (PyUnicode_Check(encoding)) {
+               encoding = _PyUnicode_AsDefaultEncodedString(encoding, NULL);
+               if (encoding == NULL)
+                       return NULL;
+       }
        if (!PyString_Check(encoding)) {
                PyErr_SetString(PyExc_TypeError,
                                "encoding name must be a string.");