summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-09-09 07:04:36 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-09-09 07:04:36 (GMT)
commit14b785192bb2b83b7826e9c0374c6d63e63f0f04 (patch)
tree0ed4b81db98e6900b22f71f9fe2763c080084b24 /Python
parentf7bfcfbb68d71611e7ffae3de7b425c68433f59a (diff)
downloadcpython-14b785192bb2b83b7826e9c0374c6d63e63f0f04.zip
cpython-14b785192bb2b83b7826e9c0374c6d63e63f0f04.tar.gz
cpython-14b785192bb2b83b7826e9c0374c6d63e63f0f04.tar.bz2
#3705: Fix crash when given a non-ascii value on the command line for the "-c" and "-m" parameters
Second part, for Windows. Reviewed by Antoine Pitrou
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 9c077fe..13e46ad 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -2804,6 +2804,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;
@@ -2847,9 +2848,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;
@@ -2860,7 +2861,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);
}