From: Victor Stinner Date: Mon, 18 Oct 2010 12:15:34 +0000 (+0000) Subject: get_code_from_data() uses the filesystem encoding to encode the module path, X-Git-Tag: v3.2a4~437 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2a94f4c0ef140b1d6de389e406ad8af34afbf167;p=python get_code_from_data() uses the filesystem encoding to encode the module path, instead of utf-8. --- diff --git a/Modules/zipimport.c b/Modules/zipimport.c index 0b9ad181f4..4334319046 100644 --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -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; }