Skip to content
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

Closed
asdfasdfasdfasdfasdfasdfasdf mannequin opened this issue Nov 14, 2010 · 4 comments
Closed

Python does not work on an IPv6 only host #54623

asdfasdfasdfasdfasdfasdfasdf mannequin opened this issue Nov 14, 2010 · 4 comments
Labels
3.7 (EOL) end of life type-bug An unexpected behavior, bug, or error

Comments

@asdfasdfasdfasdfasdfasdfasdf
Copy link
Mannequin

BPO 10414
Nosy @loewis, @gpshead

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:

assignee = None
closed_at = None
created_at = <Date 2010-11-14.04:35:17.144>
labels = ['type-bug', '3.7']
title = 'Python does not work on an IPv6 only host'
updated_at = <Date 2016-11-23.02:40:04.689>
user = 'https://bugs.python.org/asdfasdfasdfasdfasdfasdfasdf'

bugs.python.org fields:

activity = <Date 2016-11-23.02:40:04.689>
actor = 'gregory.p.smith'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = []
creation = <Date 2010-11-14.04:35:17.144>
creator = 'asdfasdfasdfasdfasdfasdfasdf'
dependencies = []
files = []
hgrepos = []
issue_num = 10414
keywords = []
message_count = 3.0
messages = ['121174', '121185', '281535']
nosy_count = 3.0
nosy_names = ['loewis', 'gregory.p.smith', 'asdfasdfasdfasdfasdfasdfasdf']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue10414'
versions = ['Python 2.7', 'Python 3.6', 'Python 3.7']

@asdfasdfasdfasdfasdfasdfasdf
Copy link
Mannequin Author

(socket.gethostbyname doesn't return an ipv6 address)
So just to start with I know the documentation says [0] "and getaddrinfo() should be used instead for IPv4/v6 dual stack support."
However, the getaddrinfo() method provides more information than required. Why can't getaddrinfo support ipv6 ? or a method for ipv6 added to the socket module to make getting a host address by name easier (for ipv6) ?

[0] - http://docs.python.org/library/socket.html#socket.gethostbyname

@loewis
Copy link
Mannequin

loewis mannequin commented Nov 14, 2010

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.

@loewis loewis mannequin closed this as completed Nov 14, 2010
@gpshead
Copy link
Member

gpshead commented Nov 23, 2016

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.

@gpshead gpshead added the 3.7 (EOL) end of life label Nov 23, 2016
@gpshead gpshead reopened this Nov 23, 2016
@gpshead gpshead changed the title socket.gethostbyname doesn't return an ipv6 address Python does not work on an IPv6 only host Nov 23, 2016
@gpshead gpshead added the type-bug An unexpected behavior, bug, or error label Nov 23, 2016
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@AA-Turner
Copy link
Member

Closing as a duplicate of the (newer) #82082.

A

@AA-Turner AA-Turner closed this as not planned Won't fix, can't repro, duplicate, stale Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants