summaryrefslogtreecommitdiffstats
path: root/Modules/getpath.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-08-13 23:29:08 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-08-13 23:29:08 (GMT)
commitf2e08b34f1fa50e99f8cab0a21721be2d1bb38b8 (patch)
tree01336b2c925f2c2ae2b7dd9df20010c4c25c49cd /Modules/getpath.c
parente9b428f9977f8733e6b0d2c321c093779f95080f (diff)
downloadcpython-f2e08b34f1fa50e99f8cab0a21721be2d1bb38b8.zip
cpython-f2e08b34f1fa50e99f8cab0a21721be2d1bb38b8.tar.gz
cpython-f2e08b34f1fa50e99f8cab0a21721be2d1bb38b8.tar.bz2
Create _Py_wchar2char() function, reverse of _Py_char2wchar()
* Use _Py_wchar2char() in _wstat() and _Py_wfopen() * Document _Py_char2wchar()
Diffstat (limited to 'Modules/getpath.c')
-rw-r--r--Modules/getpath.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c
index fff502e..faf8b56 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -139,13 +139,16 @@ static wchar_t *lib_python = L"lib/python" VERSION;
static int
_wstat(const wchar_t* path, struct stat *buf)
{
- char fname[PATH_MAX];
- size_t res = wcstombs(fname, path, sizeof(fname));
- if (res == (size_t)-1) {
+ int err;
+ char *fname;
+ fname = _Py_wchar2char(path);
+ if (fname == NULL) {
errno = EINVAL;
return -1;
}
- return stat(fname, buf);
+ err = stat(fname, buf);
+ PyMem_Free(fname);
+ return err;
}
#endif