Index: Python/sysmodule.c =================================================================== --- Python/sysmodule.c (révision 85302) +++ Python/sysmodule.c (copie de travail) @@ -1659,12 +1659,14 @@ #ifdef HAVE_REALPATH static wchar_t* -_wrealpath(const wchar_t *path, wchar_t *resolved_path) +_wrealpath(const wchar_t *path, wchar_t *resolved_path, size_t resolved_size) { char *cpath; char cresolved_path[PATH_MAX]; char *res; size_t r; + PyObject *unicode; + cpath = _Py_wchar2char(path); if (cpath == NULL) { errno = EINVAL; @@ -1674,8 +1676,13 @@ PyMem_Free(cpath); if (res == NULL) return NULL; - r = mbstowcs(resolved_path, cresolved_path, PATH_MAX); - if (r == (size_t)-1 || r >= PATH_MAX) { + unicode = PyUnicode_DecodeFSDefault(cresolved_path); + if (unicode == NULL) + return NULL; + r = PyUnicode_AsWideChar((PyUnicodeObject*)unicode, + resolved_path, resolved_size); + Py_DECREF(unicode); + if (r == -1 || r == resolved_size) { errno = EINVAL; return NULL; } @@ -1769,9 +1776,8 @@ #else /* All other filename syntaxes */ if (_HAVE_SCRIPT_ARGUMENT(argc, argv)) { #if defined(HAVE_REALPATH) - if (_wrealpath(argv0, fullpath)) { + if (_wrealpath(argv0, fullpath, sizeof(fullpath)/sizeof(fullpath[0]))) argv0 = fullpath; - } #endif p = wcsrchr(argv0, SEP); }