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

Roel Schroeven rschroev_nospam_ml at fastmail.fm
Tue Nov 6 18:38:17 CET 2007


Martin v. Löwis schreef:
>>> 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.
>>>
> Sure - but what does stat then do when passed NUL?

AFAIK then it doesn't fill in the size and time fields of the structure 
(or sets them to a useless/invalid value).

(See http://msdn2.microsoft.com/en-us/library/14h5k7ff(vs.71).aspx)

> 
>> GetFileAttributes() doesn't return those, just the FAT filesystem
>> attributes. GetFileSize and GetFileTime fail.
> 
> Ok, so how does msvcrt stat() manage to fill these fields if those
> functions fail?

See above: if stat() (_stat() actually) is called on NUL (or another 
device), I don't think it does anything useful with these fields.

-- 
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
   -- Isaac Asimov

Roel Schroeven



More information about the Python-Dev mailing list