summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-10-18 12:15:34 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-10-18 12:15:34 (GMT)
commit2a94f4c0ef140b1d6de389e406ad8af34afbf167 (patch)
tree5411a12596a99dcd715d035f85c6082c43802e89 /Modules
parentd36c8217e130bac34ea8c95c8351c47e24c401e2 (diff)
downloadcpython-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.c15
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;
}