diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-07 11:06:49 +0000 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-07 11:06:49 +0000 |
commit | 7ae7c87b058137537bdc2b7f1d8e585aa0245c1c (patch) | |
tree | c23f7910cea32d9381d663c46c68123094601f71 /Python/sysmodule.c | |
parent | afa88b5dac1b068ccc33b65cd4da400a290b137e (diff) | |
download | cpython-git-7ae7c87b058137537bdc2b7f1d8e585aa0245c1c.tar.gz |
_wrealpath() and _Py_wreadlink() support surrogates (PEP 383)
Use _Py_wchar2char() to support surrogate characters in the input path.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r-- | Python/sysmodule.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 97809d27b0..e95a91f042 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1661,16 +1661,17 @@ makeargvobject(int argc, wchar_t **argv) static wchar_t* _wrealpath(const wchar_t *path, wchar_t *resolved_path) { - char cpath[PATH_MAX]; + char *cpath; char cresolved_path[PATH_MAX]; char *res; size_t r; - r = wcstombs(cpath, path, PATH_MAX); - if (r == (size_t)-1 || r >= PATH_MAX) { + cpath = _Py_wchar2char(path); + if (cpath == NULL) { errno = EINVAL; return NULL; } res = realpath(cpath, cresolved_path); + PyMem_Free(cpath); if (res == NULL) return NULL; r = mbstowcs(resolved_path, cresolved_path, PATH_MAX); |