File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -319,6 +319,23 @@ PyObject *PyCodec_Encode(PyObject *object,
319319 PyObject * args = NULL , * result = NULL ;
320320 PyObject * v ;
321321
322+ /* XXX short-cut a few common file system
323+ encodings for now, as otherwise the import
324+ code can't load the codec registry. */
325+ if (strcmp (encoding , "utf-8" ) == 0 && PyUnicode_Check (object )) {
326+ return PyUnicode_EncodeUTF8 (PyUnicode_AS_UNICODE (object ),
327+ PyUnicode_GET_SIZE (object ),
328+ errors );
329+ }
330+ #if defined(MS_WINDOWS ) && defined(HAVE_USABLE_WCHAR_T )
331+ if (strcmp (encoding , "mbcs" ) == 0 && PyUnicode_Check (object )) {
332+ return PyUnicode_EncodeMBCS (PyUnicode_AS_UNICODE (object ),
333+ PyUnicode_GET_SIZE (object ),
334+ errors );
335+ }
336+ #endif
337+
338+
322339 encoder = PyCodec_Encoder (encoding );
323340 if (encoder == NULL )
324341 goto onError ;
You can’t perform that action at this time.
0 commit comments