changeset: 95155:ad5521dd7b80 user: Victor Stinner date: Tue Mar 24 12:16:28 2015 +0100 files: Include/fileutils.h Modules/getpath.c Python/fileutils.c description: Issue #23753: Move _Py_wstat() from Python/fileutils.c to Modules/getpath.c I expected more users of _Py_wstat(), but in practice it's only used by Modules/getpath.c. Move the function because it's not needed on Windows. Windows uses PC/getpathp.c which uses the Win32 API (ex: GetFileAttributesW()) not the POSIX API. diff -r 6303795f035a -r ad5521dd7b80 Include/fileutils.h --- a/Include/fileutils.h Tue Mar 24 12:01:30 2015 +0100 +++ b/Include/fileutils.h Tue Mar 24 12:16:28 2015 +0100 @@ -15,10 +15,6 @@ const wchar_t *text, size_t *error_pos); -PyAPI_FUNC(int) _Py_wstat( - const wchar_t* path, - struct stat *buf); - #ifndef Py_LIMITED_API #ifdef MS_WINDOWS diff -r 6303795f035a -r ad5521dd7b80 Modules/getpath.c --- a/Modules/getpath.c Tue Mar 24 12:01:30 2015 +0100 +++ b/Modules/getpath.c Tue Mar 24 12:16:28 2015 +0100 @@ -131,6 +131,23 @@ static wchar_t progpath[MAXPATHLEN+1]; static wchar_t *module_search_path = NULL; +/* Get file status. Encode the path to the locale encoding. */ + +static int +_Py_wstat(const wchar_t* path, struct stat *buf) +{ + int err; + char *fname; + fname = Py_EncodeLocale(path, NULL); + if (fname == NULL) { + errno = EINVAL; + return -1; + } + err = stat(fname, buf); + PyMem_Free(fname); + return err; +} + static void reduce(wchar_t *dir) { diff -r 6303795f035a -r ad5521dd7b80 Python/fileutils.c --- a/Python/fileutils.c Tue Mar 24 12:01:30 2015 +0100 +++ b/Python/fileutils.c Tue Mar 24 12:16:28 2015 +0100 @@ -520,23 +520,6 @@ } -/* Get file status. Encode the path to the locale encoding. */ -int -_Py_wstat(const wchar_t* path, struct stat *buf) -{ - int err; - char *fname; - fname = Py_EncodeLocale(path, NULL); - if (fname == NULL) { - errno = EINVAL; - return -1; - } - err = stat(fname, buf); - PyMem_Free(fname); - return err; -} - - #ifdef MS_WINDOWS static __int64 secs_between_epochs = 11644473600; /* Seconds between 1.1.1601 and 1.1.1970 */