
Why don't we get an ERRNO.py (at least on unix systems)
Dear readers,
and Guido at first, after much help from the list, I started doing
some CGI coding, and managed to get a working ident inside my script (to
work around an apache glitch I still don't understand). Now, the code is
general enough, but the error handling is (at least) rudimentary, since we
have the single exception socket.error raised. Now, socket.error gives
something of a little more use, namely, the 2-ble <errno, errname>, but I
don't think we could rely on error names for error checking (say what
happens if you have a localized libc, and need to work with LANG set).
Then comes the errno, but it is inherently changing from one system to the
other (just checked making ERRNO.py with h2py on a Solaris and a Linux
sytem). The only invariant part is the posix mandated error name, which I
could hope will remain the same even on `good' PC c compilers. Therefore,
I think that generating and adding such a module at compile/install time
could make only good to us.
As a matter of fact, here I am attaching some lines I got applying wdiff
to the (sorted) Solaris and Linux ERRNO.py files. As you can see, there
are four different kind of error names: some error names which share the
same error number on both systems, some other which are present only on
solaris or on linux, and then the (many) other ones, which share the same
name, but have different numbers.
Yours,
lorenzo
PS what I really needed was the ECONNREFUSED error number, which I am now
certain I couldn't rely upon, at least until we'll have an ERRNO.py
installed...
PPS I still don't understand all the error are classes thing, but, if it
would mean we can access in a simpler way to those two parts of the double
doing a chech for
raised.errno
and printing
raised.errmessage
It is great.
edited wdiff output:
---------------------------------------------------------------------
# Generated by h2py from [-/usr/include/asm/errno.h-] {+sol_errno.h+}
EADDRINUSE = [-98-] {+125+}
EADDRNOTAVAIL = [-99-] {+126+}
EADV = 68
EBUSY = 16
[...]
{+ECANCELED = 47+}
[...]
ECONNREFUSED = [-111-] {+146+}
ECONNRESET = [-104-] {+131+}
EDEADLK = [-35-] {+45+}
EDEADLOCK = [-EDEADLK-] {+56+}
EDESTADDRREQ = [-89-] {+96+}
EDOM = 33
[-EDOTDOT = 73-]