mirror of
https://github.com/python/cpython.git
synced 2025-10-28 17:13:08 +00:00
Allow encoding names to be unicode strings.
This commit is contained in:
parent
583118a535
commit
af199faa9b
1 changed files with 5 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue