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

Robert Brewer fumanchu at amor.org
Wed Nov 17 22:08:59 CET 2004


"Martin v. Löwis" wrote:
> Sent: Wednesday, November 17, 2004 12:31 PM
> To: Robert Brewer
> Cc: python-dev at python.org
> Subject: Re: [Python-Dev] os.access versus os.exist
> 
> 
> Robert Brewer wrote:
> > 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.
> 
> No. Python faking up errors that the platform doesn't provide is evil.
> You are entitled to precisely the error that the platform reported.
> 
> Now, MSVC stat() is severely constraint, in several ways (e.g. it
> doesn't support sub-second time-stamps, either), so rewriting stat
> with plain Win32 API might be reasonable, at which point giving
> more precise error would be an option.
> 
> > 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).
> 
> It sure looks like a bug - but one of msvcrt.dll.

OK. I'll file a small doc patch for os.path.exists, then, I think. Thanks!


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org


More information about the Python-Dev mailing list