mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Use unicode and remove support for some uses of str8.
This commit is contained in:
parent
5b0fdc9d0a
commit
6ea45d3341
8 changed files with 59 additions and 100 deletions
|
@ -261,22 +261,19 @@ 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)) {
|
||||
if (!PyUnicode_Check(encoding)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"encoding name must be a string.");
|
||||
return NULL;
|
||||
}
|
||||
enc = PyUnicode_AsString(encoding, NULL);
|
||||
if (enc == NULL)
|
||||
return NULL;
|
||||
|
||||
cofunc = getmultibytecodec();
|
||||
if (cofunc == NULL)
|
||||
return NULL;
|
||||
|
||||
enc = PyString_AS_STRING(encoding);
|
||||
for (codec = codec_list; codec->encoding[0]; codec++)
|
||||
if (strcmp(codec->encoding, enc) == 0)
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue