mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Short-cut lookup of utf-8 codec, to make import work
on OSX.
This commit is contained in:
parent
9b9905b2f4
commit
641d5cc6a6
1 changed files with 17 additions and 0 deletions
|
@ -319,6 +319,23 @@ PyObject *PyCodec_Encode(PyObject *object,
|
||||||
PyObject *args = NULL, *result = NULL;
|
PyObject *args = NULL, *result = NULL;
|
||||||
PyObject *v;
|
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);
|
encoder = PyCodec_Encoder(encoding);
|
||||||
if (encoder == NULL)
|
if (encoder == NULL)
|
||||||
goto onError;
|
goto onError;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue