On OS X 10.6.8, I'm getting the following result for test_socket:
[cpython] % ./python.exe -m test test_socket
[1/1] test_socket
/Users/geoff/Documents/programming/cpython/Lib/test/test_socket.py:1721: RuntimeWarning: received malformed or improperly-truncated ancillary data
result = sock.recvmsg(bufsize, *args)
/Users/geoff/Documents/programming/cpython/Lib/test/test_socket.py:1812: RuntimeWarning: received malformed or improperly-truncated ancillary data
result = sock.recvmsg_into([buf], *args)
test test_socket failed -- Traceback (most recent call last):
File "/Users/geoff/Documents/programming/cpython/Lib/test/test_socket.py", line 1169, in testGetaddrinfo
socket.getaddrinfo("localhost", None, 0, 0, 0, socket.AI_NUMERICSERV)
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
1 test failed:
test_socket
According to the OS X manpage for getaddrinfo(3), (and RFC 3493) this error is the expected behavior for a POSIX socket implementation:
AI_NUMERICSERV If the AI_NUMERICSERV bit is set, then a
non-null servname string supplied shall be
a numeric port string. Otherwise, an
EAI_NONAME error shall be returned. This
bit shall prevent any type of name resolu-
tion service (for example, NIS+) from
being invoked.
(servname is the 2nd argument to getaddrinfo(), where the test passes None. EAI_NONAME is Errno 8.)
Confirmed on 2.7.6, 3.3 and current HEAD of 3.4; the offending test code didn't exist in 3.2 and earlier.
|
Ned:
>>> socket.gethostbyname("localhost")
'127.0.0.1'
>>> socket.getaddrinfo("localhost", "00", 0, 0, 0, socket.AI_NUMERICSERV)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/socket.py", line 530, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
And to show that using AI_NUMERICSERV isn't *completely* broken on my machine:
>>> socket.getaddrinfo("localhost", "80", 0, 0, 0, socket.AI_NUMERICSERV)
[(<AddressFamily.AF_INET: 2>, <SocketType.SOCK_DGRAM: 2>, 17, '', ('127.0.0.1', 80)), (<AddressFamily.AF_INET: 2>, <SocketType.SOCK_STREAM: 1>, 6, '', ('127.0.0.1', 80)), (<AddressFamily.AF_INET6: 30>, <SocketType.SOCK_DGRAM: 2>, 17, '', ('::1', 80, 0, 0)), (<AddressFamily.AF_INET6: 30>, <SocketType.SOCK_STREAM: 1>, 6, '', ('::1', 80, 0, 0)), (<AddressFamily.AF_INET6: 30>, <SocketType.SOCK_DGRAM: 2>, 17, '', ('fe80::1%lo0', 80, 0, 1)), (<AddressFamily.AF_INET6: 30>, <SocketType.SOCK_STREAM: 1>, 6, '', ('fe80::1%lo0', 80, 0, 1))]
|