
On Fri, 8 Apr 2011 14:50:02 -0700 Guido van Rossum <guido@python.org> wrote:
You still have to type an explicit condition, and remember the appropriate errno mnemonic for the situation. The very notion of "errno" and its plethora of abbreviated error codes is ok for people used to C programming, but certainly alien to other programmers (how long does it take to remember that "file not found" is spelled "ENOENT"?).
Well, this is a fact of life. There are hundreds of errno codes and they vary across systems, both in names and in numbers (even if there is a handful that exist nearly everywhere and almost always have the same values). This is the nature of system calls, and some operating systems just have a richer set of error conditions that they present to the (advanced) programmer.
Well, errnos are only the POSIX API side of system calls. For example, a seasoned Windows C programmer might not have faced a single EBADF or ENOENT in their entire career, since the Win32 API doesn't use those. Similarly, java.io.IOException doesn't seem to have any errno-alike member, but it does have subclasses named e.g. FileNotFoundException. (http://download.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html) Looking at .Net, System.IO.IOException does have a numerical "HResult" member, but it doesn't seem related to POSIX errnos (“HRESULT is a 32-bit value, divided into three different fields: a severity code, a facility code, and an error code”). It also has a couple of subclasses such as FileNotFoundException. (http://msdn.microsoft.com/en-us/library/system.io.ioexception.aspx)
The fact that exception messages typically indicate the errno *number*, not mnemonic, is an additional annoyance (errno numbers are not standardized and can vary from system to system).
That would seem to be a problem with the str() and/or repr() of OSError, and perhaps we can fix it there.
True. Regards Antoine.