diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-11-28 20:33:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-28 20:33:20 (GMT) |
commit | ac577d7d0bd27a69921ced14c09172235ceebab5 (patch) | |
tree | 0d8e39b6dbab0cd260764fa8acaf0390a8c509b6 /Lib/asyncio | |
parent | 4d193bcc2560b824389e4d98d9d8b9b34e33dbaf (diff) | |
download | cpython-ac577d7d0bd27a69921ced14c09172235ceebab5.zip cpython-ac577d7d0bd27a69921ced14c09172235ceebab5.tar.gz cpython-ac577d7d0bd27a69921ced14c09172235ceebab5.tar.bz2 |
bpo-32154: Remove asyncio.windows_utils.socketpair (#4609)
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/test_utils.py | 6 | ||||
-rw-r--r-- | Lib/asyncio/windows_utils.py | 50 |
2 files changed, 1 insertions, 55 deletions
diff --git a/Lib/asyncio/test_utils.py b/Lib/asyncio/test_utils.py index f797b2f..32d3b0b 100644 --- a/Lib/asyncio/test_utils.py +++ b/Lib/asyncio/test_utils.py @@ -35,12 +35,6 @@ from .log import logger from test import support -if sys.platform == 'win32': # pragma: no cover - from .windows_utils import socketpair -else: - from socket import socketpair # pragma: no cover - - def dummy_ssl_context(): if ssl is None: return None diff --git a/Lib/asyncio/windows_utils.py b/Lib/asyncio/windows_utils.py index d65ea17..3b41097 100644 --- a/Lib/asyncio/windows_utils.py +++ b/Lib/asyncio/windows_utils.py @@ -17,7 +17,7 @@ import tempfile import warnings -__all__ = ['socketpair', 'pipe', 'Popen', 'PIPE', 'PipeHandle'] +__all__ = ['pipe', 'Popen', 'PIPE', 'PipeHandle'] # Constants/globals @@ -29,54 +29,6 @@ STDOUT = subprocess.STDOUT _mmap_counter = itertools.count() -if hasattr(socket, 'socketpair'): - # Since Python 3.5, socket.socketpair() is now also available on Windows - socketpair = socket.socketpair -else: - # Replacement for socket.socketpair() - def socketpair(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0): - """A socket pair usable as a self-pipe, for Windows. - - Origin: https://gist.github.com/4325783, by Geert Jansen. - Public domain. - """ - if family == socket.AF_INET: - host = '127.0.0.1' - elif family == socket.AF_INET6: - host = '::1' - else: - raise ValueError("Only AF_INET and AF_INET6 socket address " - "families are supported") - if type != socket.SOCK_STREAM: - raise ValueError("Only SOCK_STREAM socket type is supported") - if proto != 0: - raise ValueError("Only protocol zero is supported") - - # We create a connected TCP socket. Note the trick with setblocking(0) - # that prevents us from having to create a thread. - lsock = socket.socket(family, type, proto) - try: - lsock.bind((host, 0)) - lsock.listen(1) - # On IPv6, ignore flow_info and scope_id - addr, port = lsock.getsockname()[:2] - csock = socket.socket(family, type, proto) - try: - csock.setblocking(False) - try: - csock.connect((addr, port)) - except (BlockingIOError, InterruptedError): - pass - csock.setblocking(True) - ssock, _ = lsock.accept() - except: - csock.close() - raise - finally: - lsock.close() - return (ssock, csock) - - # Replacement for os.pipe() using handles instead of fds |