@@ -194,6 +194,9 @@ _Py_wchar2char(const wchar_t *text)
194194 perhaps for cygwin/mingw builds?
195195*/
196196#if defined(HAVE_STAT ) && !defined(MS_WINDOWS )
197+
198+ /* Get file status. Encode the path to the locale encoding. */
199+
197200int
198201_Py_wstat (const wchar_t * path , struct stat * buf )
199202{
@@ -210,9 +213,11 @@ _Py_wstat(const wchar_t* path, struct stat *buf)
210213}
211214#endif
212215
213- /* Call _wstat() on Windows, or stat() otherwise. Only fill st_mode
214- attribute on Windows. Return 0 on success, -1 on stat error or (if
215- PyErr_Occurred()) unicode error. */
216+ /* Call _wstat() on Windows, or encode the path to the filesystem encoding and
217+ call stat() otherwise. Only fill st_mode attribute on Windows.
218+
219+ Return 0 on success, -1 on _wstat() / stat() error or (if PyErr_Occurred())
220+ unicode error. */
216221
217222int
218223_Py_stat (PyObject * path , struct stat * statbuf )
@@ -236,6 +241,9 @@ _Py_stat(PyObject *path, struct stat *statbuf)
236241#endif
237242}
238243
244+ /* Open a file. Use _wfopen() on Windows, encode the path to the locale
245+ encoding and use fopen() otherwise. */
246+
239247FILE *
240248_Py_wfopen (const wchar_t * path , const wchar_t * mode )
241249{
@@ -260,9 +268,11 @@ _Py_wfopen(const wchar_t *path, const wchar_t *mode)
260268#endif
261269}
262270
263- /* Call _wfopen() on Windows, or fopen() otherwise. Return the new file
264- object on success, or NULL if the file cannot be open or (if
265- PyErr_Occurred()) on unicode error */
271+ /* Call _wfopen() on Windows, or encode the path to the filesystem encoding and
272+ call fopen() otherwise.
273+
274+ Return the new file object on success, or NULL if the file cannot be open or
275+ (if PyErr_Occurred()) on unicode error */
266276
267277FILE *
268278_Py_fopen (PyObject * path , const char * mode )
@@ -288,6 +298,10 @@ _Py_fopen(PyObject *path, const char *mode)
288298}
289299
290300#ifdef HAVE_READLINK
301+
302+ /* Read value of symbolic link. Encode the path to the locale encoding, decode
303+ the result from the locale encoding. */
304+
291305int
292306_Py_wreadlink (const wchar_t * path , wchar_t * buf , size_t bufsiz )
293307{
@@ -320,6 +334,10 @@ _Py_wreadlink(const wchar_t *path, wchar_t *buf, size_t bufsiz)
320334#endif
321335
322336#ifdef HAVE_REALPATH
337+
338+ /* Return the canonicalized absolute pathname. Encode path to the locale
339+ encoding, decode the result from the locale encoding. */
340+
323341wchar_t *
324342_Py_wrealpath (const wchar_t * path ,
325343 wchar_t * resolved_path , size_t resolved_path_size )
@@ -346,6 +364,8 @@ _Py_wrealpath(const wchar_t *path,
346364}
347365#endif
348366
367+ /* Get the current directory. Decode the path from the locale encoding. */
368+
349369wchar_t *
350370_Py_wgetcwd (wchar_t * buf , size_t size )
351371{
0 commit comments