[Python-Dev] Special file "nul" in Windows and os.stat

"Martin v. Löwis" martin at v.loewis.de
Wed Nov 7 07:24:01 CET 2007


> In order to keep the higher accuracy timestamps for normal files and to
> maintain the old behavior, my recommendation would be that the existing
> implementation of win32_stat/win32_wstat be extended to use
> FindFileFirst if GetFileAttributes* fails. I would be willing to do the
> legwork for such a patch if everyone agrees this is the appropriate
> solution.

That, in general, might be wrong. os.stat("*.txt") should fail, even
though FindFirstFile will succeed when passed that string.

That was my primary motivation for not using FindFirstFile by default:
it may succeed even if the string being passed does not denote a file
name.

> * As an aside, Martin, I find the argument that "hard-wiring is bad" to
> be against what is actually occurring in the posixmodule. For that
> matter, the S_IFEXEC flag is hardwired to path in (*.bat, *.cmd, *.exe,
> *.com) despite the fact that the platform says it is really anything in
> the list of os.getenv('PATHEXT'), but I suppose that is a bug for
> another day.

No. See the source of the C library - the algorithm Python uses now is
(or should be) the same as the one of the C library. Of course, you
may argue that then msvcrt has the same bug.

Regards,
Martin


More information about the Python-Dev mailing list