Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4f447fb

Browse files
author
Hirokazu Yamamoto
committed
Issue #5273: Fixed import failure on unicode path. (especially on windows)
1 parent 7c9875c commit 4f447fb

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

Python/import.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -990,13 +990,15 @@ update_compiled_module(PyCodeObject *co, char *pathname)
990990
{
991991
PyObject *oldname, *newname;
992992

993-
if (!PyUnicode_CompareWithASCIIString(co->co_filename, pathname))
994-
return 0;
995-
996-
newname = PyUnicode_FromString(pathname);
993+
newname = PyUnicode_DecodeFSDefault(pathname);
997994
if (newname == NULL)
998995
return -1;
999996

997+
if (!PyUnicode_Compare(co->co_filename, newname)) {
998+
Py_DECREF(newname);
999+
return 0;
1000+
}
1001+
10001002
oldname = co->co_filename;
10011003
Py_INCREF(oldname);
10021004
update_code_filenames(co, oldname, newname);

0 commit comments

Comments
 (0)