cpython: 6098141155f9 (original) (raw)

Mercurial > cpython

changeset 93053:6098141155f9

Issue #18643: Add socket.socketpair() on Windows. [#18643]

Charles-François Natali cf.natali@gmail.com
date Tue, 14 Oct 2014 21:22:44 +0100
parents 424fbf011176
children 1e1f275ee9a1
files Doc/library/socket.rst Lib/socket.py Lib/test/test_socket.py Misc/NEWS
diffstat 4 files changed, 56 insertions(+), 3 deletions(-)[+] [-] Doc/library/socket.rst 4 Lib/socket.py 51 Lib/test/test_socket.py 2 Misc/NEWS 2

line wrap: on

line diff

--- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -350,7 +350,6 @@ The following functions all create :ref: type, and protocol number. Address family, socket type, and protocol number are as for the :func:.socket function above. The default family is :const:AF_UNIX if defined on the platform; otherwise, the default is :const:AF_INET.

@@ -361,6 +360,9 @@ The following functions all create :ref: .. versionchanged:: 3.4 The returned sockets are now non-inheritable.

+ .. function:: create_connection(address[, timeout[, source_address]])

--- a/Lib/socket.py +++ b/Lib/socket.py @@ -76,6 +76,11 @@ SocketType = IntEnum('SocketType', if name.isupper() and name.startswith('SOCK_')}) globals().update(SocketType.members) + +_LOCALHOST = '127.0.0.1' +_LOCALHOST_V6 = '::1' + + def _intenum_converter(value, enum_klass): """Convert a numeric family value to an IntEnum member. @@ -468,6 +473,52 @@ if hasattr(_socket, "socketpair"): b = socket(family, type, proto, b.detach()) return a, b +else: +

+

+ +socketpair.doc = """socketpair([family[, type[, proto]]]) -> (socket object, socket object) +Create a pair of socket objects from the sockets returned by the platform +socketpair() function. +The arguments are the same as for socket() except the default family is AF_UNIX +if defined on the platform; otherwise, the default is AF_INET. +""" _blocking_errnos = { EAGAIN, EWOULDBLOCK }

--- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -3728,8 +3728,6 @@ class TCPCloserTest(ThreadedTCPSocketTes self.cli.connect((HOST, self.port)) time.sleep(1.0) -@unittest.skipUnless(hasattr(socket, 'socketpair'),

@unittest.skipUnless(thread, 'Threading required for this test.') class BasicSocketPairTest(SocketPairTest):

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -177,6 +177,8 @@ Core and Builtins Library ------- +- Issue #18643: Add socket.socketpair() on Windows. +