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

Chris Mellon arkanes at gmail.com
Wed Oct 31 20:31:37 CET 2007

On Oct 30, 2007 4:10 PM, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> >> My question now is what specific kernel32 functions Python 2.4
> >> calls to determine that NUL is a file; before that question
> >> is sufficiently answered, I don't think any action should be
> >> taken.
> >>
> >
> > os.path.exist() in win32 just calls os.stat() and decides it doesn't
> > exist if an error is returned. os.stat() uses the vcrt stat()in 2.4,
> > but 2.5 implements it directly in terms of win32 api to deal with
> > limitations in the vcrt implementation.
> That doesn't really answer the question, though - you merely state
> that Python 2.4 calls the CRT, but then my question is still what
> kernel32 functions are called to have stat on NUL succeed.

I'm not 100% (it calls it through a function pointer and I'm not sure
I tracked it down correctly), but I think it calls it through the C
stat() function. In other words, it doesn't use any kernel32 functions
directly, it calls the stat() that's exported from the MSVCRT.

> > Interestingly, plain old GetFileAttributes() works, and returns
> What about the other attributes (like modification time, size, etc)?

GetFileAttributes() doesn't return those, just the FAT filesystem
attributes. GetFileSize and GetFileTime fail.

> Regards,
> Martin

More information about the Python-Dev mailing list