Index: Python/import.c =================================================================== --- Python/import.c (revision 69635) +++ Python/import.c (working copy) @@ -988,13 +988,15 @@ { PyObject *oldname, *newname; - if (!PyUnicode_CompareWithASCIIString(co->co_filename, pathname)) - return 0; - - newname = PyUnicode_FromString(pathname); + newname = PyUnicode_DecodeFSDefault(pathname); if (newname == NULL) return -1; + if (!PyUnicode_Compare(co->co_filename, newname)) { + Py_DECREF(newname); + return 0; + } + oldname = co->co_filename; Py_INCREF(oldname); update_code_filenames(co, oldname, newname);