From af199faa9bcbe73753224f174075693bd98b64ea Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 17 May 2007 18:56:39 +0000 Subject: [PATCH] Allow encoding names to be unicode strings. --- Modules/cjkcodecs/cjkcodecs.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h index 71c54f093fc..c79b304a038 100644 --- a/Modules/cjkcodecs/cjkcodecs.h +++ b/Modules/cjkcodecs/cjkcodecs.h @@ -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.");