diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-18 12:15:34 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-18 12:15:34 (GMT) |
commit | 2a94f4c0ef140b1d6de389e406ad8af34afbf167 (patch) | |
tree | 5411a12596a99dcd715d035f85c6082c43802e89 /Modules | |
parent | d36c8217e130bac34ea8c95c8351c47e24c401e2 (diff) | |
download | cpython-2a94f4c0ef140b1d6de389e406ad8af34afbf167.zip cpython-2a94f4c0ef140b1d6de389e406ad8af34afbf167.tar.gz cpython-2a94f4c0ef140b1d6de389e406ad8af34afbf167.tar.bz2 |
get_code_from_data() uses the filesystem encoding to encode the module path,
instead of utf-8.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/zipimport.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Modules/zipimport.c b/Modules/zipimport.c index 0b9ad18..4334319 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; } |