[Python-Dev] Return error codes from getaddrinfo.
python-dev at xhaus.com
Thu Jun 28 09:59:37 CEST 2007
>>I want jython to use the same errno symbolic constants as cpython, to
>>ease portability of code.
> That will be very difficult to achieve, as Python is (deliberately)
> not even consistent across systems. Instead, it reports what the
> platform reports, so you should do the same in Java.
I think I need to explain myself more clearly; I'm looking for the
errno.SYMBOLIC_CONSTANT for errors returned by the getaddrinfo function.
Take the following lines from the cpython 2.5 httplib.
Line 998 - 1014
buf = self._ssl.read(self._bufsize)
except socket.sslerror, err:
if (err == socket.SSL_ERROR_WANT_READ
or err == socket.SSL_ERROR_WANT_WRITE):
if (err == socket.SSL_ERROR_ZERO_RETURN
or err == socket.SSL_ERROR_EOF):
except socket.error, err:
if err == errno.EINTR:
if err == errno.EBADF:
# XXX socket was closed?
How can that code work on jython, other than if
A: The jython errno module contains definitions for EINTR and EBADF
B: The socket module raises the exceptions with the correct
errno.SYMBOLIC_CONSTANTS, in the same circumstances as the cpython module.
(The actual integers don't matter, but thanks anyway to the three
separate people who informed me that googling "11001" was the solution
to my problem).
And then there are the non-portable uses of error numbers, like this
snippet from the 2.5 httplib:
except socket.error, v:
if v == 32: # Broken pipe
Do these examples make it clearer why and in what way I want the jython
errno symbolic constants to be the same as cpython?
More information about the Python-Dev