[issue25138] test_socket: socket.EAI_NODATA doesn't exist on FreeBSD

Martin Panter report at bugs.python.org
Mon Sep 21 07:48:38 CEST 2015


Martin Panter added the comment:

Looking at this more closely, the check seems to be there just to check if basic DNS lookups are working. It was added for Issue 12804. One option might be to replace it with a support.transient_internet() handler:

# Check for internet access before running test (issue #12804).
with support.transient_internet('python.org'):
    socket.gethostbyname('python.org')
# these should all be successful
...

According to the socket module source code, gethostbyname() calls the OS-level getaddrinfo() rather gethostbyname(), hence the “gaierror” handling. The error codes that get raised seem to be a platform-dependent mess, but transient_internet() looks like it catches EAI_NONAME, _FAIL, _NODATA and WSANO_DATA (among others). EAI_NODATA seems to have been removed from RFC 3493 and current Posix, but was apparently originally meant to be for looking up records that did exist but (say) did not have any IP v4 addresses.

----------
nosy: +nadeem.vawda

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25138>
_______________________________________


More information about the Python-bugs-list mailing list