From 4f447fb9a1605b7c3f1e5513b925b9213ef9480c Mon Sep 17 00:00:00 2001 From: Hirokazu Yamamoto Date: Wed, 4 Mar 2009 01:52:10 +0000 Subject: [PATCH] Issue #5273: Fixed import failure on unicode path. (especially on windows) --- Python/import.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Python/import.c b/Python/import.c index 11cbc58189c..1cd3dc701dc 100644 --- a/Python/import.c +++ b/Python/import.c @@ -990,13 +990,15 @@ update_compiled_module(PyCodeObject *co, char *pathname) { 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);