summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-11-11 23:04:59 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-11-11 23:04:59 (GMT)
commit9a5499b4e54f1d74dfe41772d780511c8ad1120c (patch)
tree4aac685d27ffba930b8c36f4dc356aed6728a0b3 /Python
parentd3013ffa49e889ff96ed967f574aa01b91b09f12 (diff)
downloadcpython-9a5499b4e54f1d74dfe41772d780511c8ad1120c.zip
cpython-9a5499b4e54f1d74dfe41772d780511c8ad1120c.tar.gz
cpython-9a5499b4e54f1d74dfe41772d780511c8ad1120c.tar.bz2
#3705: Command-line arguments were not correctly decoded when the
terminal does not use UTF8. Now the code propagates the unicode string as far as possible, and avoids the conversion to char* which implicitely uses utf-8. Reviewed by Benjamin.
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Python/import.c b/Python/import.c
index 564ace88..2bad2e5 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -2793,6 +2793,7 @@ call_find_module(char *name, PyObject *path)
{
extern int fclose(FILE *);
PyObject *fob, *ret;
+ PyObject *pathobj;
struct filedescr *fdp;
char pathname[MAXPATHLEN+1];
FILE *fp = NULL;
@@ -2836,9 +2837,9 @@ call_find_module(char *name, PyObject *path)
fob = Py_None;
Py_INCREF(fob);
}
- ret = Py_BuildValue("Os(ssi)",
- fob, pathname, fdp->suffix, fdp->mode, fdp->type);
- Py_DECREF(fob);
+ pathobj = PyUnicode_DecodeFSDefault(pathname);
+ ret = Py_BuildValue("NN(ssi)",
+ fob, pathobj, fdp->suffix, fdp->mode, fdp->type);
PyMem_FREE(found_encoding);
return ret;
@@ -2849,7 +2850,9 @@ imp_find_module(PyObject *self, PyObject *args)
{
char *name;
PyObject *path = NULL;
- if (!PyArg_ParseTuple(args, "s|O:find_module", &name, &path))
+ if (!PyArg_ParseTuple(args, "es|O:find_module",
+ Py_FileSystemDefaultEncoding, &name,
+ &path))
return NULL;
return call_find_module(name, path);
}