STINNER Victor <victor.stin...@haypocalc.com> added the comment:

_Py_stat.patch: create _Py_stat() function. It will be used in import.c and 
zipimport.c.

I added the function to import.c because, initially, I only used it there. But 
it's maybe not the best place for such function. posixmodule.c doesn't fit 
because it is not part of the bootstrap process.

I created this function to get full unicode support on Windows (don't fallback 
to bytes using the evil mbcs encoding).

In import.c and zipimport.c, it is used to check if the path is a regular file 
or if the path is a directory. That's why _Py_stat() only fills st_mode 
attribute (it's just enough).

A better API would be maybe functions checking directly these properties? Maybe 
Py_isdir() (as os.path.isdir()) and Py_isreg()? Or if you prefer longer names: 
Py_is_directory() ad Py_is_regular_file()? Such functions can be implemented 
differently, eg. use GetFileAttributesW on Windows. I say that because of a 
comment found in NullImporter_init():

    /* see issue1293 and issue3677:
     * stat() on Windows doesn't recognise paths like
     * "e:\\shared\\" and "\\\\whiterab-c2znlh\\shared" as dirs.
     */

----------
Added file: http://bugs.python.org/file18448/_Py_stat.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9425>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to