Commit b808d892 authored by Felix Kaiser's avatar Felix Kaiser Committed by Jason Madden

Bugfix: ipv6: when binding to "", use AF_INET6

That'll make the socket work both with IPv4 and IPv6.
parent 7e0da131
......@@ -375,7 +375,7 @@ def _extract_family(host):
def _parse_address(address):
if isinstance(address, tuple):
if ':' in address[0]:
if not address[0] or ':' in address[0]:
return _socket.AF_INET6, address
return _socket.AF_INET, address
elif isinstance(address, string_types):
......@@ -386,9 +386,9 @@ def _parse_address(address):
host = ''
return family, (host, int(port))
else:
return _socket.AF_INET, ('', int(address))
return _socket.AF_INET6, ('', int(address))
elif isinstance(address, integer_types):
return _socket.AF_INET, ('', int(address))
return _socket.AF_INET6, ('', int(address))
else:
raise TypeError('Expected tuple or string, got %s' % type(address))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment