diff options
Diffstat (limited to 'Modules/cjkcodecs/cjkcodecs.h')
-rw-r--r-- | Modules/cjkcodecs/cjkcodecs.h | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h index c79b304..9449c1f 100644 --- a/Modules/cjkcodecs/cjkcodecs.h +++ b/Modules/cjkcodecs/cjkcodecs.h @@ -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; |