diff Python/import.c @ 49103:f7123d45d0c4

#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
author Amaury Forgeot d'Arc <amauryfa@gmail.com>
date Tue, 09 Sep 2008 07:04:36 +0000
parents 3fa066d2a397
children f6650f247598
line wrap: on
line diff
--- a/Python/import.c	Tue Sep 09 06:42:00 2008 +0000
+++ b/Python/import.c	Tue Sep 09 07:04:36 2008 +0000
@@ -2804,6 +2804,7 @@
 {
 	extern int fclose(FILE *);
 	PyObject *fob, *ret;
+	PyObject *pathobj;
 	struct filedescr *fdp;
 	char pathname[MAXPATHLEN+1];
 	FILE *fp = NULL;
@@ -2847,9 +2848,9 @@
 		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 @@
 {
 	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);
 }