summaryrefslogtreecommitdiff
path: root/Python/codecs.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2007-06-11 04:19:13 +0000
committerMartin v. Löwis <martin@v.loewis.de>2007-06-11 04:19:13 +0000
commitdfbc4144f6643213b5a4e0edc6f8ae198df14604 (patch)
tree86125ec8b9f0106b76e494b9da2626ce12b158a9 /Python/codecs.c
parentc6b1a554d18ebd42a6c4bbc7092d7ab74ce81591 (diff)
downloadcpython-dfbc4144f6643213b5a4e0edc6f8ae198df14604.tar.gz
Short-cut lookup of utf-8 codec, to make import work
on OSX.
Diffstat (limited to 'Python/codecs.c')
-rw-r--r--Python/codecs.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/Python/codecs.c b/Python/codecs.c
index 3aa1f386e7..1ba6009122 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;