]> granicus.if.org Git - python/commitdiff
get_code_from_data() uses the filesystem encoding to encode the module path,
authorVictor Stinner <victor.stinner@haypocalc.com>
Mon, 18 Oct 2010 12:15:34 +0000 (12:15 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Mon, 18 Oct 2010 12:15:34 +0000 (12:15 +0000)
instead of utf-8.

Modules/zipimport.c

index 0b9ad181f4d7bc99a7add6a440ae88585e51d329..43343190468f66d74858e9c6a03e3636b1b6d5f8 100644 (file)
@@ -1137,24 +1137,23 @@ get_code_from_data(ZipImporter *self, int ispackage, int isbytecode,
                    time_t mtime, PyObject *toc_entry)
 {
     PyObject *data, *code;
-    char *modpath;
+    PyObject *modpath;
 
     data = get_data(self->archive, toc_entry);
     if (data == NULL)
         return NULL;
 
-    modpath = _PyUnicode_AsString(PyTuple_GetItem(toc_entry, 0));
+    modpath = PyUnicode_EncodeFSDefault(PyTuple_GetItem(toc_entry, 0));
     if (modpath == NULL) {
         Py_DECREF(data);
         return NULL;
     }
 
-    if (isbytecode) {
-        code = unmarshal_code(modpath, data, mtime);
-    }
-    else {
-        code = compile_source(modpath, data);
-    }
+    if (isbytecode)
+        code = unmarshal_code(PyBytes_AS_STRING(modpath), data, mtime);
+    else
+        code = compile_source(PyBytes_AS_STRING(modpath), data);
+    Py_DECREF(modpath);
     Py_DECREF(data);
     return code;
 }