[Python-Dev] Return error codes from getaddrinfo.

Alan Kennedy python-dev at xhaus.com
Wed Jun 27 20:26:08 CEST 2007

Dear all,

I'm seeking enlightenment on the error codes returned by the 
socket.getaddrinfo() function.

Consider the following on python 2.5 on Windows

 >>> import urllib
 >>> urllib.urlopen("http://nonexistent")
  [snip traceback]
IOError: [Errno socket error] (11001, 'getaddrinfo failed')

So the error number is 11001.

But when I try to find a symbolic constant in the errno module 
corresponding to this error number, I can't find one.

 >>> import errno
 >>> errno.errorcode[11]
 >>> errno.errorcode[11001]
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
KeyError: 11001

Looking through the C source for the socket module doesn't provide any 
clarity (although my C is a little rusty). That module has a special 
function, set_gaierror(), for handling error returns from getaddrinfo. 
But I can't see if or how the resulting error codes relate to the errno 

Is there supposed to be symbolic constants in the errno module 
corresponding to getaddrinfo errors?

I want jython to use the same errno symbolic constants as cpython, to 
ease portability of code.



More information about the Python-Dev mailing list