[Python-Dev] POSIX [Fuzziness in io module specs]

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Sep 20 01:43:13 CEST 2009


Pascal Chambon wrote:
> 
> And let the 
> filepointer untouched, simply because there are no reasons to move it,

On some systems it may not be possible for the file pointer to
be positioned past the end of the file (I think Classic MacOS
was like that).

> I had the feeling that IOErrors were for operations on file streams 
> (opening, writing/reading, closing...), whereas OSErrors were for 
> manipulations on filesystems (renaming, linking, stating...)

I always thought the distinction was that IOError contains
a C library errno value, whereas OSError contains an
OS-specific error code. So system calls that aren't part
of the C stdlib need to use OSError, at least on some
platforms.

I don't see that file errors vs. everything else is
a very useful distinction to make when catching exceptions.
I almost always end up catching EnvironmentError to make
sure I get both, particularly when working cross-platform.

What we could do with is better platform-independent
ways of distinguishing particular error conditions,
such as file not found, out of space, etc., either
using subclasses of IOError or mapping error codes
to a set of platform-independent ones.

-- 
Greg


More information about the Python-Dev mailing list