summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-10-07 11:06:49 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-10-07 11:06:49 (GMT)
commit7ae7c87b058137537bdc2b7f1d8e585aa0245c1c (patch)
treec23f7910cea32d9381d663c46c68123094601f71 /Modules
parentafa88b5dac1b068ccc33b65cd4da400a290b137e (diff)
downloadcpython-7ae7c87b058137537bdc2b7f1d8e585aa0245c1c.zip
cpython-7ae7c87b058137537bdc2b7f1d8e585aa0245c1c.tar.gz
cpython-7ae7c87b058137537bdc2b7f1d8e585aa0245c1c.tar.bz2
_wrealpath() and _Py_wreadlink() support surrogates (PEP 383)
Use _Py_wchar2char() to support surrogate characters in the input path.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/getpath.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c
index 6f2e537..06d0cae 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -179,15 +179,18 @@ _wgetcwd(wchar_t *buf, size_t size)
int
_Py_wreadlink(const wchar_t *path, wchar_t *buf, size_t bufsiz)
{
+ char *cpath;
char cbuf[PATH_MAX];
- char cpath[PATH_MAX];
int res;
- size_t r1 = wcstombs(cpath, path, PATH_MAX);
- if (r1 == (size_t)-1 || r1 >= PATH_MAX) {
+ size_t r1;
+
+ cpath = _Py_wchar2char(path);
+ if (cpath == NULL) {
errno = EINVAL;
return -1;
}
res = (int)readlink(cpath, cbuf, PATH_MAX);
+ PyMem_Free(cpath);
if (res == -1)
return -1;
if (res == PATH_MAX) {