diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2007-06-11 04:19:13 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2007-06-11 04:19:13 (GMT) |
commit | 641d5cc6a61e19a01d62b61b6b5b5d9dd8663d12 (patch) | |
tree | b28b086b97f88cd7d11b2604e7851b131ee2dc4f /Python/codecs.c | |
parent | 9b9905b2f435b28ed0e971a1187f90a3e273f642 (diff) | |
download | cpython-641d5cc6a61e19a01d62b61b6b5b5d9dd8663d12.zip cpython-641d5cc6a61e19a01d62b61b6b5b5d9dd8663d12.tar.gz cpython-641d5cc6a61e19a01d62b61b6b5b5d9dd8663d12.tar.bz2 |
Short-cut lookup of utf-8 codec, to make import work
on OSX.
Diffstat (limited to 'Python/codecs.c')
-rw-r--r-- | Python/codecs.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Python/codecs.c b/Python/codecs.c index 3aa1f38..1ba6009 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -319,6 +319,23 @@ PyObject *PyCodec_Encode(PyObject *object, PyObject *args = NULL, *result = NULL; PyObject *v; + /* XXX short-cut a few common file system + encodings for now, as otherwise the import + code can't load the codec registry. */ + if (strcmp(encoding, "utf-8") == 0 && PyUnicode_Check(object)) { + return PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(object), + PyUnicode_GET_SIZE(object), + errors); + } +#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) + if (strcmp(encoding, "mbcs") == 0 && PyUnicode_Check(object)) { + return PyUnicode_EncodeMBCS(PyUnicode_AS_UNICODE(object), + PyUnicode_GET_SIZE(object), + errors); + } +#endif + + encoder = PyCodec_Encoder(encoding); if (encoder == NULL) goto onError; |