diff options
author | Yury Selivanov <yury@magic.io> | 2016-11-21 17:47:41 -0500 |
---|---|---|
committer | Yury Selivanov <yury@magic.io> | 2016-11-21 17:47:41 -0500 |
commit | 5cb0c09fa6384990da0f2c47b92bd0ae8f87ff5d (patch) | |
tree | 50a00554d94ff537a857ffea693546d5cda36e9b /Lib/asyncio/base_events.py | |
parent | bf87126a636bddf2d9a8f432215fe2efb98ba8fe (diff) | |
parent | dab05847385c14fe76773d30f75f2bdc5b2ab7e3 (diff) | |
download | cpython-git-5cb0c09fa6384990da0f2c47b92bd0ae8f87ff5d.tar.gz |
Merge 3.5 (issue #28652)
Diffstat (limited to 'Lib/asyncio/base_events.py')
-rw-r--r-- | Lib/asyncio/base_events.py | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index 4eed46856a..0df58c5f87 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -98,14 +98,6 @@ def _is_dgram_socket(sock): return (sock.type & socket.SOCK_DGRAM) == socket.SOCK_DGRAM -def _is_ip_socket(sock): - if sock.family == socket.AF_INET: - return True - if hasattr(socket, 'AF_INET6') and sock.family == socket.AF_INET6: - return True - return False - - def _ipaddr_info(host, port, family, type, proto): # Try to skip getaddrinfo if "host" is already an IP. Users might have # handled name resolution in their own code and pass in resolved IPs. @@ -796,9 +788,15 @@ class BaseEventLoop(events.AbstractEventLoop): if sock is None: raise ValueError( 'host and port was not specified and no sock specified') - if not _is_stream_socket(sock) or not _is_ip_socket(sock): + if not _is_stream_socket(sock): + # We allow AF_INET, AF_INET6, AF_UNIX as long as they + # are SOCK_STREAM. + # We support passing AF_UNIX sockets even though we have + # a dedicated API for that: create_unix_connection. + # Disallowing AF_UNIX in this method, breaks backwards + # compatibility. raise ValueError( - 'A TCP Stream Socket was expected, got {!r}'.format(sock)) + 'A Stream Socket was expected, got {!r}'.format(sock)) transport, protocol = yield from self._create_connection_transport( sock, protocol_factory, ssl, server_hostname) @@ -1055,9 +1053,9 @@ class BaseEventLoop(events.AbstractEventLoop): else: if sock is None: raise ValueError('Neither host/port nor sock were specified') - if not _is_stream_socket(sock) or not _is_ip_socket(sock): + if not _is_stream_socket(sock): raise ValueError( - 'A TCP Stream Socket was expected, got {!r}'.format(sock)) + 'A Stream Socket was expected, got {!r}'.format(sock)) sockets = [sock] server = Server(self, sockets) |