diff options
author | Charles-François Natali <neologix@free.fr> | 2011-11-27 12:50:15 +0100 |
---|---|---|
committer | Charles-François Natali <neologix@free.fr> | 2011-11-27 12:50:15 +0100 |
commit | 2e62c03aea1fc45dc2028f43b0cf2284167e3bf3 (patch) | |
tree | 749012026a7985be01e5e542bb9cd85a35454ccf /Python/fileutils.c | |
parent | ebf9b25e02def456b5f921814e3e1456d827f844 (diff) | |
parent | bad59cc495132cd01bbf643ba108dc42149a2733 (diff) | |
download | cpython-2e62c03aea1fc45dc2028f43b0cf2284167e3bf3.tar.gz |
Null merge.
Diffstat (limited to 'Python/fileutils.c')
-rw-r--r-- | Python/fileutils.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c index c563eaa5fb..0afa415d59 100644 --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -244,8 +244,12 @@ _Py_stat(PyObject *path, struct stat *statbuf) #ifdef MS_WINDOWS int err; struct _stat wstatbuf; + wchar_t *wpath; - err = _wstat(PyUnicode_AS_UNICODE(path), &wstatbuf); + wpath = PyUnicode_AsUnicode(path); + if (wpath == NULL) + return -1; + err = _wstat(wpath, &wstatbuf); if (!err) statbuf->st_mode = wstatbuf.st_mode; return err; @@ -297,14 +301,19 @@ FILE* _Py_fopen(PyObject *path, const char *mode) { #ifdef MS_WINDOWS + wchar_t *wpath; wchar_t wmode[10]; int usize; + wpath = PyUnicode_AsUnicode(path); + if (wpath == NULL) + return NULL; + usize = MultiByteToWideChar(CP_ACP, 0, mode, -1, wmode, sizeof(wmode)); if (usize == 0) return NULL; - return _wfopen(PyUnicode_AS_UNICODE(path), wmode); + return _wfopen(wpath, wmode); #else FILE *f; PyObject *bytes = PyUnicode_EncodeFSDefault(path); |