[Python-Dev] os.access versus os.exist

Robert Brewer fumanchu at amor.org
Tue Nov 16 22:59:24 CET 2004


Martin v. Löwis wrote:
> Robert Brewer wrote:
> > Inside the app (running under LocalSystem on the same Win2k 
> machine):
> >    os.stat() raises OSError: [Errno 2] No such file or directory,
> >    os.path.exists() returns False, and
> >    os.access() returns False.
> 
> LocalSystem cannot access network shares. However, this is OT for
> python-dev.

Completely understood about LocalSystem. But IMO, os.stat should raise a more specific and correct error. As you pointed out, calling open() raises "IOError: [Errno 13] Permission denied"; it would be nice if stat did the same (in my example). The platform-specific API call (for example, Windows _stati64) doesn't provide this--it would require another test inside posix_do_stat to return a more appropriate error. But it would be a nice touch for us end-users.

In my opinion, "no such file" is the wrong error message and is therefore a bug. But I can accept others disagreeing, since os.stat() simply wraps Windows' _stat* calls (at least, in my example).


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org


More information about the Python-Dev mailing list