]> granicus.if.org Git - python/commitdiff
Issue #5273: Fixed import failure on unicode path. (especially on windows)
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Wed, 4 Mar 2009 01:52:10 +0000 (01:52 +0000)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Wed, 4 Mar 2009 01:52:10 +0000 (01:52 +0000)
Python/import.c

index 11cbc58189c1832819d92f976f29ab7b5303b952..1cd3dc701dc45ef5e2ab6d0b982add0e20753d0b 100644 (file)
@@ -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);