Allow encoding names to be unicode strings.

This commit is contained in:
Guido van Rossum 2007-05-17 18:56:39 +00:00
parent 583118a535
commit af199faa9b
1 changed files with 5 additions and 0 deletions

View 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.");