Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 49708:fb725366f9ac
#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.
| author | Amaury Forgeot d'Arc <amauryfa@gmail.com> |
|---|---|
| date | Tue, 11 Nov 2008 23:04:59 +0000 |
| parents | aa6e649599ad |
| children | e987e0df8f48 2ee4653927f7 |
line wrap: on
line diff
--- a/Python/import.c Tue Nov 11 21:43:42 2008 +0000 +++ b/Python/import.c Tue Nov 11 23:04:59 2008 +0000 @@ -2793,6 +2793,7 @@ { extern int fclose(FILE *); PyObject *fob, *ret; + PyObject *pathobj; struct filedescr *fdp; char pathname[MAXPATHLEN+1]; FILE *fp = NULL; @@ -2836,9 +2837,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; @@ -2849,7 +2850,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); }
