asyncio: _check_resolved_address() must also accept IPv6 without flow_info and

scope_id: (host, port).
This commit is contained in:
Victor Stinner 2014-02-20 21:59:38 +01:00
parent 35669ae77e
commit a90e8edaea
2 changed files with 7 additions and 4 deletions

View File

@ -48,7 +48,7 @@ def _check_resolved_address(sock, address):
if family == socket.AF_INET: if family == socket.AF_INET:
host, port = address host, port = address
elif family == socket.AF_INET6: elif family == socket.AF_INET6:
host, port, flow_info, scope_id = address host, port = address[:2]
else: else:
return return

View File

@ -1335,11 +1335,14 @@ class EventLoopTestsMixin:
'selector': self.loop._selector.__class__.__name__}) 'selector': self.loop._selector.__class__.__name__})
def test_sock_connect_address(self): def test_sock_connect_address(self):
families = [(socket.AF_INET, ('www.python.org', 80))] addresses = [(socket.AF_INET, ('www.python.org', 80))]
if support.IPV6_ENABLED: if support.IPV6_ENABLED:
families.append((socket.AF_INET6, ('www.python.org', 80, 0, 0))) addresses.extend((
(socket.AF_INET6, ('www.python.org', 80)),
(socket.AF_INET6, ('www.python.org', 80, 0, 0)),
))
for family, address in families: for family, address in addresses:
for sock_type in (socket.SOCK_STREAM, socket.SOCK_DGRAM): for sock_type in (socket.SOCK_STREAM, socket.SOCK_DGRAM):
sock = socket.socket(family, sock_type) sock = socket.socket(family, sock_type)
with sock: with sock: