Index: Python/pythonrun.c =================================================================== --- Python/pythonrun.c (revision 64087) +++ Python/pythonrun.c (working copy) @@ -697,7 +697,7 @@ PyObject *std = NULL; int status = 0, fd; PyObject * encoding_attr; - char *encoding, *errors; + char *encoding = NULL, *errors; /* Hack to avoid a nasty recursion issue when Python is invoked in verbose mode: pre-import the Latin-1 and UTF-8 codecs */ Index: Python/import.c =================================================================== --- Python/import.c (revision 64087) +++ Python/import.c (working copy) @@ -1318,19 +1318,26 @@ if (!v) return NULL; if (PyUnicode_Check(v)) { - v = _PyUnicode_AsDefaultEncodedString(v, NULL); + v = PyUnicode_AsEncodedString(v, + Py_FileSystemDefaultEncoding, NULL); if (v == NULL) return NULL; } - if (!PyBytes_Check(v)) + else if (!PyBytes_Check(v)) continue; + else + Py_INCREF(v); + base = PyBytes_AS_STRING(v); size = PyBytes_GET_SIZE(v); len = size; if (len + 2 + namelen + MAXSUFFIXSIZE >= buflen) { + Py_DECREF(v); continue; /* Too long */ } strcpy(buf, base); + Py_DECREF(v); + if (strlen(buf) != len) { continue; /* v contains '\0' */ } @@ -3105,8 +3112,8 @@ if (!_PyArg_NoKeywords("NullImporter()", kwds)) return -1; - if (!PyArg_ParseTuple(args, "s:NullImporter", - &path)) + if (!PyArg_ParseTuple(args, "es:NullImporter", + Py_FileSystemDefaultEncoding, &path)) return -1; pathlen = strlen(path);