-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python does not work on an IPv6 only host #54623
Comments
(socket.gethostbyname doesn't return an ipv6 address) [0] - http://docs.python.org/library/socket.html#socket.gethostbyname |
Python has a policy of exposing low-level APIs as-is, i.e. the way the operating system implements them. gethostbyname is an old BSD socket API function that is limited to IPv4, and Python exposes it as such. If you want another convenience function, I recommend to write it yourself, and then use it in your code. |
Reopening to expand upon this issue which is still a large problem: If you run on an IPv6-only Linux host, the following standard library tests all fail: test_asynchat, test_asyncio, test_asyncore, test_docxmlrpc, test_epoll, test_httpservers, test_logging, test_multiprocessing_fork, test_multiprocessing_forkserver, test_os, test_poplib, test_pydoc, test_robotparser, test_ssl, test_support, test_telnetlib, test_urllib2_localnet, test_urllib_response, test_uuid, test_xmlrpc I won't attempt to paste all of the errors into here but the errors have a few themes, here's a couple examples: ERROR: test_arp_getnode (test.test_uuid.TestUUID) Traceback (most recent call last):
File "lib/python3.4/test/test_uuid.py", line 324, in test_arp_getnode
node = uuid._arp_getnode()
File "lib/python3.4/uuid.py", line 364, in _arp_getnode
ip_addr = socket.gethostbyname(socket.gethostname())
socket.gaierror: [Errno -2] Name or service not known ERROR: test_getwelcome (test.test_poplib.TestPOP3Class) Traceback (most recent call last):
File "lib/python3.4/test/test_poplib.py", line 246, in setUp
self.server = DummyPOP3Server((HOST, PORT))
File "lib/python3.4/test/test_poplib.py", line 199, in __init__
self.create_socket(af, socket.SOCK_STREAM)
File "lib/python3.4/asyncore.py", line 289, in create_socket
sock = socket.socket(family, type)
File "lib/python3.4/socket.py", line 126, in __init__
_socket.socket.__init__(self, family, type, proto, fileno)
OSError: [Errno 97] Address family not supported by protocol (yes I know those are from an old 3.4 test suite run but code inspection of 3.6 shows that the underlying issues appear to remain) Someone will need to setup an IPv6 only host in order to work on these and can generate the full modern list of errors. It appears we have things that explicitly use IPv4 specific socket flags when unwarranted or use old API calls that don't deal with IPv6 at all, and represent IP addresses as strings within most of our standard library rather than adopting our own high level ipaddress module for API compatibility reasons. (see https://bugs.python.org/issue20215 regarding TCPServer not supporting IPv6 at all) Taking this on will keep Python relevant for the future without forcing people to jump through hoops or abandon the stdlib and only use third party networking libraries. |
Closing as a duplicate of the (newer) #82082. A |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: