mirror of https://github.com/python/cpython.git
Allow encoding names to be unicode strings.
This commit is contained in:
parent
583118a535
commit
af199faa9b
|
@ -261,6 +261,11 @@ getcodec(PyObject *self, PyObject *encoding)
|
||||||
const MultibyteCodec *codec;
|
const MultibyteCodec *codec;
|
||||||
const char *enc;
|
const char *enc;
|
||||||
|
|
||||||
|
if (PyUnicode_Check(encoding)) {
|
||||||
|
encoding = _PyUnicode_AsDefaultEncodedString(encoding, NULL);
|
||||||
|
if (encoding == NULL)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
if (!PyString_Check(encoding)) {
|
if (!PyString_Check(encoding)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"encoding name must be a string.");
|
"encoding name must be a string.");
|
||||||
|
|
Loading…
Reference in New Issue