From e404d40ce8a6944b3df006fbedef91e32cfa1ab1 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Sun, 16 Sep 2018 13:04:30 +0100 Subject: [PATCH 01/48] switched to dynamic importing --- trio/socket.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/trio/socket.py b/trio/socket.py index 93af20e383..429f3e5be3 100644 --- a/trio/socket.py +++ b/trio/socket.py @@ -1,8 +1,16 @@ -# This is a public namespace, so we don't want to expose any non-underscored -# attributes that aren't actually part of our public API. But it's very +# This is a public namespace, so we dont want to expose any non-underscored +# attributes that arent actually part of our public API. But its very # annoying to carefully always use underscored names for module-level # temporaries, imports, etc. when implementing the module. So we put the # implementation in an underscored module, and then re-export the public parts # here. -from ._socket import * -from ._socket import __all__ +import importlib + +#from ._socket import * +#from ._socket import __all__ +#import _socket as socket +from ._socket import (gaierror, herror, gethostname, ntohs, htonl, htons, inet_aton, inet_ntoa, inet_pton, inet_ntop, sethostname, if_nameindex, if_nametoindex, if_indextoname, set_custom_hostname_resolver, set_custom_socket_factory, getaddrinfo, getnameinfo, getprotobyname, from_stdlib_socket, fromfd, socketpair, socket, SocketType) + +_sock_module = importlib.import_module('_socket') +print(_sock_module.__dict__) +globals().update({_name: getattr(_sock_module, _name) for _name in [_uname for _uname in _sock_module.__dict__ if _uname.isupper()]}) From 3fcd475267c3223feace2bd0f51d5a0ddf9ab998 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Sun, 16 Sep 2018 13:10:58 +0100 Subject: [PATCH 02/48] Added AF_APPLETALK manually to see the effect --- trio/socket.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/trio/socket.py b/trio/socket.py index 429f3e5be3..62a37f0750 100644 --- a/trio/socket.py +++ b/trio/socket.py @@ -5,6 +5,7 @@ # implementation in an underscored module, and then re-export the public parts # here. import importlib +import socket #from ._socket import * #from ._socket import __all__ @@ -14,3 +15,6 @@ _sock_module = importlib.import_module('_socket') print(_sock_module.__dict__) globals().update({_name: getattr(_sock_module, _name) for _name in [_uname for _uname in _sock_module.__dict__ if _uname.isupper()]}) + +AF_APPLETALK = socket.AF_APPLETALK + From 711e7b498406dc1310d16e44c59071fdfdc98e6d Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Sun, 16 Sep 2018 13:24:32 +0100 Subject: [PATCH 03/48] Removed AF_APPLETALK again as tests failed --- trio/socket.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/trio/socket.py b/trio/socket.py index 62a37f0750..429f3e5be3 100644 --- a/trio/socket.py +++ b/trio/socket.py @@ -5,7 +5,6 @@ # implementation in an underscored module, and then re-export the public parts # here. import importlib -import socket #from ._socket import * #from ._socket import __all__ @@ -15,6 +14,3 @@ _sock_module = importlib.import_module('_socket') print(_sock_module.__dict__) globals().update({_name: getattr(_sock_module, _name) for _name in [_uname for _uname in _sock_module.__dict__ if _uname.isupper()]}) - -AF_APPLETALK = socket.AF_APPLETALK - From 8ea86abfcafbeb5fd731fc871162cac13a0916d5 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Sun, 16 Sep 2018 13:35:36 +0100 Subject: [PATCH 04/48] imported _socket directly as socket --- trio/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/trio/__init__.py b/trio/__init__.py index 8372c35920..fee37ba803 100644 --- a/trio/__init__.py +++ b/trio/__init__.py @@ -64,7 +64,8 @@ # Imported by default from . import hazmat -from . import socket +#from . import socket +from . import _socket as socket from . import abc from . import ssl # Not imported by default: testing From 268cc3382989f62ded57fc358c31a5f8f331714d Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Sun, 16 Sep 2018 13:37:39 +0100 Subject: [PATCH 05/48] Added print for better understanding (temporarly) --- trio/__init__.py | 1 + trio/socket.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/trio/__init__.py b/trio/__init__.py index fee37ba803..2476f15eef 100644 --- a/trio/__init__.py +++ b/trio/__init__.py @@ -66,6 +66,7 @@ from . import hazmat #from . import socket from . import _socket as socket +print(dir(socket)) from . import abc from . import ssl # Not imported by default: testing diff --git a/trio/socket.py b/trio/socket.py index 429f3e5be3..ec1bc3d17f 100644 --- a/trio/socket.py +++ b/trio/socket.py @@ -12,5 +12,4 @@ from ._socket import (gaierror, herror, gethostname, ntohs, htonl, htons, inet_aton, inet_ntoa, inet_pton, inet_ntop, sethostname, if_nameindex, if_nametoindex, if_indextoname, set_custom_hostname_resolver, set_custom_socket_factory, getaddrinfo, getnameinfo, getprotobyname, from_stdlib_socket, fromfd, socketpair, socket, SocketType) _sock_module = importlib.import_module('_socket') -print(_sock_module.__dict__) globals().update({_name: getattr(_sock_module, _name) for _name in [_uname for _uname in _sock_module.__dict__ if _uname.isupper()]}) From b9ee0d7c1f4a60195c85cddf34b61a9773d0888e Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Sun, 16 Sep 2018 13:44:12 +0100 Subject: [PATCH 06/48] Reverted to import of socket --- trio/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trio/__init__.py b/trio/__init__.py index 2476f15eef..9a2ce035f7 100644 --- a/trio/__init__.py +++ b/trio/__init__.py @@ -64,8 +64,8 @@ # Imported by default from . import hazmat -#from . import socket -from . import _socket as socket +from . import socket +#from . import _socket as socket print(dir(socket)) from . import abc from . import ssl From 7bbb52b6e3b502ef10a1653e57fe5e86c16f94ab Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Sun, 16 Sep 2018 19:12:29 +0100 Subject: [PATCH 07/48] Dynamic updates are simply not picked up by static analysis tools --- trio/__init__.py | 5 +++-- trio/_socket.py | 56 +++++++++++++++++++++++++++++++++++++----------- trio/socket.py | 25 +++++++++++++++------ 3 files changed, 64 insertions(+), 22 deletions(-) diff --git a/trio/__init__.py b/trio/__init__.py index 9a2ce035f7..d14913736e 100644 --- a/trio/__init__.py +++ b/trio/__init__.py @@ -65,8 +65,9 @@ # Imported by default from . import hazmat from . import socket -#from . import _socket as socket -print(dir(socket)) +# print(f'Final Attributes: {socket.__dict__.keys()}') +from .socket import TrioSocket + from . import abc from . import ssl # Not imported by default: testing diff --git a/trio/_socket.py b/trio/_socket.py index 133b32c2b9..d70c9ee96f 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -1,5 +1,7 @@ +import importlib import os as _os -import socket as _stdlib_socket +#import socket as _stdlib_socket +_stdlib_socket = importlib.import_module('socket') import sys as _sys from functools import wraps as _wraps @@ -16,9 +18,9 @@ ################################################################ -def _reexport(name): - globals()[name] = getattr(_stdlib_socket, name) - __all__.append(name) +def _reexport(names): + globals().update(names) + __all__.extend(names) def _add_to_all(obj): @@ -72,9 +74,12 @@ async def __aexit__(self, etype, value, tb): TCP_NOTSENT_LOWAT = 25 __all__.append("TCP_NOTSENT_LOWAT") -for _name in _stdlib_socket.__dict__.keys(): - if _name == _name.upper(): - _reexport(_name) +_reexport( + { + _name: getattr(_stdlib_socket, _name) + for _name in _stdlib_socket.__dict__.keys() if _name.isupper() + } +) if _sys.platform == "win32": # See https://github.com/python-trio/trio/issues/39 @@ -92,7 +97,7 @@ async def __aexit__(self, etype, value, tb): # Simple re-exports ################################################################ -for _name in [ +_names = [ "gaierror", "herror", "gethostname", @@ -107,9 +112,33 @@ async def __aexit__(self, etype, value, tb): "if_nameindex", "if_nametoindex", "if_indextoname", -]: - if hasattr(_stdlib_socket, _name): - _reexport(_name) +] + +_reexport( + { + _name: getattr(_stdlib_socket, _name) + for _name in _names if hasattr(_stdlib_socket, _name) + } +) + +# for _name in [ +# "gaierror", +# "herror", +# "gethostname", +# "ntohs", +# "htonl", +# "htons", +# "inet_aton", +# "inet_ntoa", +# "inet_pton", +# "inet_ntop", +# "sethostname", +# "if_nameindex", +# "if_nametoindex", +# "if_indextoname", +# ]: +# if hasattr(_stdlib_socket, _name): +# _reexport(_name) ################################################################ # Overrides @@ -389,8 +418,9 @@ def __init__(self, sock): # For example, ssl.SSLSocket subclasses socket.socket, but we # certainly don't want to blindly wrap one of those. raise TypeError( - "expected object of type 'socket.socket', not '{}" - .format(type(sock).__name__) + "expected object of type 'socket.socket', not '{}".format( + type(sock).__name__ + ) ) self._sock = sock self._sock.setblocking(False) diff --git a/trio/socket.py b/trio/socket.py index ec1bc3d17f..47d2f40729 100644 --- a/trio/socket.py +++ b/trio/socket.py @@ -4,12 +4,23 @@ # temporaries, imports, etc. when implementing the module. So we put the # implementation in an underscored module, and then re-export the public parts # here. -import importlib +# import importlib -#from ._socket import * -#from ._socket import __all__ -#import _socket as socket -from ._socket import (gaierror, herror, gethostname, ntohs, htonl, htons, inet_aton, inet_ntoa, inet_pton, inet_ntop, sethostname, if_nameindex, if_nametoindex, if_indextoname, set_custom_hostname_resolver, set_custom_socket_factory, getaddrinfo, getnameinfo, getprotobyname, from_stdlib_socket, fromfd, socketpair, socket, SocketType) +from ._socket import * +from ._socket import _stdlib_socket -_sock_module = importlib.import_module('_socket') -globals().update({_name: getattr(_sock_module, _name) for _name in [_uname for _uname in _sock_module.__dict__ if _uname.isupper()]}) +# from ._socket import __all__ +# from ._socket import (gaierror, herror, gethostname, ntohs, htonl, htons, inet_aton, inet_ntoa, inet_pton, inet_ntop, sethostname, if_nameindex, if_nametoindex, if_indextoname, set_custom_hostname_resolver, set_custom_socket_factory, getaddrinfo, getnameinfo, getprotobyname, from_stdlib_socket, fromfd, socketpair, socket, SocketType) + +# _sock_module = importlib.import_module('_socket', 'trio') +# globals().update({_name: getattr(_sock_module, _name) for _name in _sock_module.__dict__.keys() if _name.isupper()}) + + +class TrioSocket: + def __init(self): + pass + + +TrioSocket.AF_APPLETALK = _stdlib_socket.AF_APPLETALK + +setattr(TrioSocket, 'AF_INET', _stdlib_socket.AF_INET) From 1b50f2a9d0b973d597e021f1eac796fe631f5fd3 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 02:31:25 +0100 Subject: [PATCH 08/48] trio/socket.py : Moved to static import of names and emoved __all__ --- trio/__init__.py | 3 - trio/_core/_io_windows.py | 4 +- trio/_core/_run.py | 13 ++-- trio/_signals.py | 2 +- trio/_socket.py | 146 ++++++++++++------------------------ trio/_sync.py | 15 ++-- trio/socket.py | 19 ----- trio/testing/_mock_clock.py | 5 +- trio/tests/test_testing.py | 5 +- 9 files changed, 74 insertions(+), 138 deletions(-) diff --git a/trio/__init__.py b/trio/__init__.py index d14913736e..8372c35920 100644 --- a/trio/__init__.py +++ b/trio/__init__.py @@ -65,9 +65,6 @@ # Imported by default from . import hazmat from . import socket -# print(f'Final Attributes: {socket.__dict__.keys()}') -from .socket import TrioSocket - from . import abc from . import ssl # Not imported by default: testing diff --git a/trio/_core/_io_windows.py b/trio/_core/_io_windows.py index d044b1f0a5..73d7cc9409 100644 --- a/trio/_core/_io_windows.py +++ b/trio/_core/_io_windows.py @@ -341,8 +341,8 @@ async def _wait_socket(self, which, sock): if sock in self._socket_waiters[which]: await _core.checkpoint() raise _core.ResourceBusyError( - "another task is already waiting to {} this socket" - .format(which) + "another task is already waiting to {} this socket". + format(which) ) self._socket_waiters[which][sock] = _core.current_task() diff --git a/trio/_core/_run.py b/trio/_core/_run.py index eb8392781e..a9cfb70dae 100644 --- a/trio/_core/_run.py +++ b/trio/_core/_run.py @@ -851,8 +851,8 @@ def _return_value_looks_like_wrong_library(value): "trio was expecting an async function, but instead it got " "{!r} – are you trying to use a library written for " "asyncio/twisted/tornado or similar? That won't work " - "without some sort of compatibility shim." - .format(async_fn) + "without some sort of compatibility shim.". + format(async_fn) ) from None raise @@ -867,8 +867,8 @@ def _return_value_looks_like_wrong_library(value): raise TypeError( "start_soon got unexpected {!r} – are you trying to use a " "library written for asyncio/twisted/tornado or similar? " - "That won't work without some sort of compatibility shim." - .format(coro) + "That won't work without some sort of compatibility shim.". + format(coro) ) if isasyncgen(coro): @@ -880,8 +880,9 @@ def _return_value_looks_like_wrong_library(value): # Give good error for: nursery.start_soon(some_sync_fn) raise TypeError( "trio expected an async function, but {!r} appears to be " - "synchronous" - .format(getattr(async_fn, "__qualname__", async_fn)) + "synchronous".format( + getattr(async_fn, "__qualname__", async_fn) + ) ) ###### diff --git a/trio/_signals.py b/trio/_signals.py index 3b910a92d1..9010c420cb 100644 --- a/trio/_signals.py +++ b/trio/_signals.py @@ -177,7 +177,7 @@ def __aiter__(self): return self async def __anext__(self): - return { await self._signal_queue.__anext__()} + return {await self._signal_queue.__anext__()} @deprecated("0.7.0", issue=354, instead=open_signal_receiver) diff --git a/trio/_socket.py b/trio/_socket.py index d70c9ee96f..643a82bcc2 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -1,7 +1,47 @@ -import importlib import os as _os -#import socket as _stdlib_socket -_stdlib_socket = importlib.import_module('socket') +import socket as _stdlib_socket +from socket import ( + gaierror, herror, gethostname, ntohs, htonl, htons, inet_aton, inet_ntoa, + inet_pton, inet_ntop, sethostname, if_nameindex, if_nametoindex, + if_indextoname, CMSG_LEN, CMSG_SPACE, CAPI, AF_UNSPEC, AF_INET, AF_UNIX, + AF_IPX, AF_APPLETALK, AF_INET6, AF_ROUTE, AF_LINK, AF_SNA, PF_SYSTEM, + AF_SYSTEM, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, SOCK_RDM, + SO_DEBUG, SO_ACCEPTCONN, SO_REUSEADDR, SO_KEEPALIVE, SO_DONTROUTE, + SO_BROADCAST, SO_USELOOPBACK, SO_LINGER, SO_OOBINLINE, SO_REUSEPORT, + SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT, SO_SNDTIMEO, SO_RCVTIMEO, + SO_ERROR, SO_TYPE, LOCAL_PEERCRED, SOMAXCONN, SCM_RIGHTS, SCM_CREDS, + MSG_OOB, MSG_PEEK, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_TRUNC, + MSG_CTRUNC, MSG_WAITALL, MSG_EOF, SOL_SOCKET, SOL_IP, SOL_TCP, SOL_UDP, + IPPROTO_IP, IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_GGP, + IPPROTO_IPV4, IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, + IPPROTO_UDP, IPPROTO_IDP, IPPROTO_HELLO, IPPROTO_ND, IPPROTO_TP, + IPPROTO_ROUTING, IPPROTO_FRAGMENT, IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_ESP, + IPPROTO_AH, IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_DSTOPTS, IPPROTO_XTP, + IPPROTO_EON, IPPROTO_PIM, IPPROTO_IPCOMP, IPPROTO_SCTP, IPPROTO_RAW, + IPPROTO_MAX, SYSPROTO_CONTROL, IPPORT_RESERVED, IPPORT_USERRESERVED, + INADDR_ANY, INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, + INADDR_ALLHOSTS_GROUP, INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, + IP_HDRINCL, IP_TOS, IP_TTL, IP_RECVOPTS, IP_RECVRETOPTS, IP_RECVDSTADDR, + IP_RETOPTS, IP_MULTICAST_IF, IP_MULTICAST_TTL, IP_MULTICAST_LOOP, + IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_DEFAULT_MULTICAST_TTL, + IP_DEFAULT_MULTICAST_LOOP, IP_MAX_MEMBERSHIPS, IPV6_JOIN_GROUP, + IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, + IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY, IPV6_CHECKSUM, + IPV6_RECVTCLASS, IPV6_RTHDR_TYPE_0, IPV6_TCLASS, TCP_NODELAY, TCP_MAXSEG, + TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN, EAI_ADDRFAMILY, EAI_AGAIN, + EAI_BADFLAGS, EAI_FAIL, EAI_FAMILY, EAI_MEMORY, EAI_NODATA, EAI_NONAME, + EAI_OVERFLOW, EAI_SERVICE, EAI_SOCKTYPE, EAI_SYSTEM, EAI_BADHINTS, + EAI_PROTOCOL, EAI_MAX, AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST, + AI_NUMERICSERV, AI_MASK, AI_ALL, AI_V4MAPPED_CFG, AI_ADDRCONFIG, + AI_V4MAPPED, AI_DEFAULT, NI_MAXHOST, NI_MAXSERV, NI_NOFQDN, NI_NUMERICHOST, + NI_NAMEREQD, NI_NUMERICSERV, NI_DGRAM, SHUT_RD, SHUT_WR, SHUT_RDWR, EBADF, + EAGAIN, EWOULDBLOCK, _LOCALHOST, _LOCALHOST_V6, _GLOBAL_DEFAULT_TIMEOUT +) +try: + from socket import IPPROTO_IPV6, TCP_NOTSENT_LOWAT +except ImportError: + pass + import sys as _sys from functools import wraps as _wraps @@ -11,31 +51,7 @@ from ._threads import run_sync_in_worker_thread from ._util import fspath -__all__ = [] - -################################################################ -# misc utilities -################################################################ - -def _reexport(names): - globals().update(names) - __all__.extend(names) - - -def _add_to_all(obj): - __all__.append(obj.__name__) - return obj - - -# Usage: -# -# async with _try_sync(): -# return sync_call_that_might_fail_with_exception() -# # we only get here if the sync call in fact did fail with a -# # BlockingIOError -# return await do_it_properly_with_a_check_point() -# class _try_sync: def __init__(self, blocking_exc_override=None): self._blocking_exc_override = blocking_exc_override @@ -69,76 +85,21 @@ async def __aexit__(self, etype, value, tb): if not hasattr(_stdlib_socket, "TCP_NOTSENT_LOWAT"): # pragma: no branch if _sys.platform == "darwin": TCP_NOTSENT_LOWAT = 0x201 - __all__.append("TCP_NOTSENT_LOWAT") + globals()['TCP_NOTSENT_LOWAT'] = TCP_NOTSENT_LOWAT elif _sys.platform == "linux": TCP_NOTSENT_LOWAT = 25 - __all__.append("TCP_NOTSENT_LOWAT") - -_reexport( - { - _name: getattr(_stdlib_socket, _name) - for _name in _stdlib_socket.__dict__.keys() if _name.isupper() - } -) + globals()['TCP_NOTSENT_LOWAT'] = TCP_NOTSENT_LOWAT if _sys.platform == "win32": # See https://github.com/python-trio/trio/issues/39 # (you can still get it from stdlib socket, of course, if you want it) - globals().pop("SO_REUSEADDR", None) - __all__.remove("SO_REUSEADDR") + del SO_REUSEADDR # As of at least 3.6, python on Windows is missing IPPROTO_IPV6 # https://bugs.python.org/issue29515 if not hasattr(_stdlib_socket, "IPPROTO_IPV6"): # pragma: no branch IPPROTO_IPV6 = 41 - __all__.append("IPPROTO_IPV6") - -################################################################ -# Simple re-exports -################################################################ - -_names = [ - "gaierror", - "herror", - "gethostname", - "ntohs", - "htonl", - "htons", - "inet_aton", - "inet_ntoa", - "inet_pton", - "inet_ntop", - "sethostname", - "if_nameindex", - "if_nametoindex", - "if_indextoname", -] - -_reexport( - { - _name: getattr(_stdlib_socket, _name) - for _name in _names if hasattr(_stdlib_socket, _name) - } -) - -# for _name in [ -# "gaierror", -# "herror", -# "gethostname", -# "ntohs", -# "htonl", -# "htons", -# "inet_aton", -# "inet_ntoa", -# "inet_pton", -# "inet_ntop", -# "sethostname", -# "if_nameindex", -# "if_nametoindex", -# "if_indextoname", -# ]: -# if hasattr(_stdlib_socket, _name): -# _reexport(_name) + globals()['IPPPROTO_IPV6'] = IPPROTO_IPV6 ################################################################ # Overrides @@ -148,7 +109,6 @@ async def __aexit__(self, etype, value, tb): _socket_factory = _core.RunVar("socket_factory") -@_add_to_all def set_custom_hostname_resolver(hostname_resolver): """Set a custom hostname resolver. @@ -181,7 +141,6 @@ def set_custom_hostname_resolver(hostname_resolver): return old -@_add_to_all def set_custom_socket_factory(socket_factory): """Set a custom socket object factory. @@ -216,7 +175,6 @@ def set_custom_socket_factory(socket_factory): _NUMERIC_ONLY = _stdlib_socket.AI_NUMERICHOST | _stdlib_socket.AI_NUMERICSERV -@_add_to_all async def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0): """Look up a numeric address given a name. @@ -278,7 +236,6 @@ def numeric_only_failure(exc): ) -@_add_to_all async def getnameinfo(sockaddr, flags): """Look up a name given a numeric address. @@ -298,7 +255,6 @@ async def getnameinfo(sockaddr, flags): ) -@_add_to_all async def getprotobyname(name): """Look up a protocol number by name. (Rarely used.) @@ -318,7 +274,6 @@ async def getprotobyname(name): ################################################################ -@_add_to_all def from_stdlib_socket(sock): """Convert a standard library :func:`socket.socket` object into a trio socket object. @@ -328,7 +283,6 @@ def from_stdlib_socket(sock): @_wraps(_stdlib_socket.fromfd, assigned=(), updated=()) -@_add_to_all def fromfd(*args, **kwargs): """Like :func:`socket.fromfd`, but returns a trio socket object. @@ -339,13 +293,12 @@ def fromfd(*args, **kwargs): if hasattr(_stdlib_socket, "fromshare"): @_wraps(_stdlib_socket.fromshare, assigned=(), updated=()) - @_add_to_all + # @_add_to_all def fromshare(*args, **kwargs): return from_stdlib_socket(_stdlib_socket.fromshare(*args, **kwargs)) @_wraps(_stdlib_socket.socketpair, assigned=(), updated=()) -@_add_to_all def socketpair(*args, **kwargs): """Like :func:`socket.socketpair`, but returns a pair of trio socket objects. @@ -356,7 +309,6 @@ def socketpair(*args, **kwargs): @_wraps(_stdlib_socket.socket, assigned=(), updated=()) -@_add_to_all def socket( family=_stdlib_socket.AF_INET, type=_stdlib_socket.SOCK_STREAM, @@ -403,7 +355,7 @@ def real_socket_type(type_num): return type_num & _SOCK_TYPE_MASK -@_add_to_all +# @_add_to_all class SocketType: def __init__(self): raise TypeError( diff --git a/trio/_sync.py b/trio/_sync.py index 7367b35af5..72f8256327 100644 --- a/trio/_sync.py +++ b/trio/_sync.py @@ -415,8 +415,9 @@ def __repr__(self): else: max_value_str = ", max_value={}".format(self._max_value) return ( - "" - .format(self._value, max_value_str, id(self)) + "".format( + self._value, max_value_str, id(self) + ) ) @property @@ -524,8 +525,9 @@ def __repr__(self): s1 = "unlocked" s2 = "" return ( - "<{} {} object at {:#x}{}>" - .format(s1, self.__class__.__name__, id(self), s2) + "<{} {} object at {:#x}{}>".format( + s1, self.__class__.__name__, id(self), s2 + ) ) def locked(self): @@ -858,8 +860,9 @@ def __init__(self, capacity): def __repr__(self): return ( - "" - .format(self.capacity, id(self), len(self._data)) + "".format( + self.capacity, id(self), len(self._data) + ) ) def qsize(self): diff --git a/trio/socket.py b/trio/socket.py index 47d2f40729..936811f36d 100644 --- a/trio/socket.py +++ b/trio/socket.py @@ -4,23 +4,4 @@ # temporaries, imports, etc. when implementing the module. So we put the # implementation in an underscored module, and then re-export the public parts # here. -# import importlib - from ._socket import * -from ._socket import _stdlib_socket - -# from ._socket import __all__ -# from ._socket import (gaierror, herror, gethostname, ntohs, htonl, htons, inet_aton, inet_ntoa, inet_pton, inet_ntop, sethostname, if_nameindex, if_nametoindex, if_indextoname, set_custom_hostname_resolver, set_custom_socket_factory, getaddrinfo, getnameinfo, getprotobyname, from_stdlib_socket, fromfd, socketpair, socket, SocketType) - -# _sock_module = importlib.import_module('_socket', 'trio') -# globals().update({_name: getattr(_sock_module, _name) for _name in _sock_module.__dict__.keys() if _name.isupper()}) - - -class TrioSocket: - def __init(self): - pass - - -TrioSocket.AF_APPLETALK = _stdlib_socket.AF_APPLETALK - -setattr(TrioSocket, 'AF_INET', _stdlib_socket.AF_INET) diff --git a/trio/testing/_mock_clock.py b/trio/testing/_mock_clock.py index a013e4da79..09d3ea7091 100644 --- a/trio/testing/_mock_clock.py +++ b/trio/testing/_mock_clock.py @@ -100,8 +100,9 @@ def __init__(self, rate=0.0, autojump_threshold=inf): def __repr__(self): return ( - "" - .format(self.current_time(), self._rate, id(self)) + "".format( + self.current_time(), self._rate, id(self) + ) ) @property diff --git a/trio/tests/test_testing.py b/trio/tests/test_testing.py index 8abf8eb5ff..a7df5275d7 100644 --- a/trio/tests/test_testing.py +++ b/trio/tests/test_testing.py @@ -322,8 +322,9 @@ async def test_mock_clock_autojump(mock_clock): real_duration = time.monotonic() - real_start print( - "Slept {} seconds in {} seconds" - .format(10 * sum(range(10)), real_duration) + "Slept {} seconds in {} seconds".format( + 10 * sum(range(10)), real_duration + ) ) assert real_duration < 1 From fc666c244077d501de576f9217100721458b4979 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 02:38:21 +0100 Subject: [PATCH 09/48] Fixed import error of some constants not found on some platforms --- trio/_socket.py | 74 ++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index 643a82bcc2..4bc19f9c68 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -3,42 +3,48 @@ from socket import ( gaierror, herror, gethostname, ntohs, htonl, htons, inet_aton, inet_ntoa, inet_pton, inet_ntop, sethostname, if_nameindex, if_nametoindex, - if_indextoname, CMSG_LEN, CMSG_SPACE, CAPI, AF_UNSPEC, AF_INET, AF_UNIX, - AF_IPX, AF_APPLETALK, AF_INET6, AF_ROUTE, AF_LINK, AF_SNA, PF_SYSTEM, - AF_SYSTEM, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, SOCK_RDM, - SO_DEBUG, SO_ACCEPTCONN, SO_REUSEADDR, SO_KEEPALIVE, SO_DONTROUTE, - SO_BROADCAST, SO_USELOOPBACK, SO_LINGER, SO_OOBINLINE, SO_REUSEPORT, - SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT, SO_SNDTIMEO, SO_RCVTIMEO, - SO_ERROR, SO_TYPE, LOCAL_PEERCRED, SOMAXCONN, SCM_RIGHTS, SCM_CREDS, - MSG_OOB, MSG_PEEK, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_TRUNC, - MSG_CTRUNC, MSG_WAITALL, MSG_EOF, SOL_SOCKET, SOL_IP, SOL_TCP, SOL_UDP, - IPPROTO_IP, IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_GGP, - IPPROTO_IPV4, IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, - IPPROTO_UDP, IPPROTO_IDP, IPPROTO_HELLO, IPPROTO_ND, IPPROTO_TP, - IPPROTO_ROUTING, IPPROTO_FRAGMENT, IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_ESP, - IPPROTO_AH, IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_DSTOPTS, IPPROTO_XTP, - IPPROTO_EON, IPPROTO_PIM, IPPROTO_IPCOMP, IPPROTO_SCTP, IPPROTO_RAW, - IPPROTO_MAX, SYSPROTO_CONTROL, IPPORT_RESERVED, IPPORT_USERRESERVED, - INADDR_ANY, INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, - INADDR_ALLHOSTS_GROUP, INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, - IP_HDRINCL, IP_TOS, IP_TTL, IP_RECVOPTS, IP_RECVRETOPTS, IP_RECVDSTADDR, - IP_RETOPTS, IP_MULTICAST_IF, IP_MULTICAST_TTL, IP_MULTICAST_LOOP, - IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_DEFAULT_MULTICAST_TTL, - IP_DEFAULT_MULTICAST_LOOP, IP_MAX_MEMBERSHIPS, IPV6_JOIN_GROUP, - IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, - IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY, IPV6_CHECKSUM, - IPV6_RECVTCLASS, IPV6_RTHDR_TYPE_0, IPV6_TCLASS, TCP_NODELAY, TCP_MAXSEG, - TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN, EAI_ADDRFAMILY, EAI_AGAIN, - EAI_BADFLAGS, EAI_FAIL, EAI_FAMILY, EAI_MEMORY, EAI_NODATA, EAI_NONAME, - EAI_OVERFLOW, EAI_SERVICE, EAI_SOCKTYPE, EAI_SYSTEM, EAI_BADHINTS, - EAI_PROTOCOL, EAI_MAX, AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST, - AI_NUMERICSERV, AI_MASK, AI_ALL, AI_V4MAPPED_CFG, AI_ADDRCONFIG, - AI_V4MAPPED, AI_DEFAULT, NI_MAXHOST, NI_MAXSERV, NI_NOFQDN, NI_NUMERICHOST, - NI_NAMEREQD, NI_NUMERICSERV, NI_DGRAM, SHUT_RD, SHUT_WR, SHUT_RDWR, EBADF, - EAGAIN, EWOULDBLOCK, _LOCALHOST, _LOCALHOST_V6, _GLOBAL_DEFAULT_TIMEOUT + if_indextoname ) + try: - from socket import IPPROTO_IPV6, TCP_NOTSENT_LOWAT + from socket import ( + IPPROTO_IPV6, TCP_NOTSENT_LOWAT, CMSG_LEN, CMSG_SPACE, CAPI, AF_UNSPEC, + AF_INET, AF_UNIX, AF_IPX, AF_APPLETALK, AF_INET6, AF_ROUTE, AF_LINK, + AF_SNA, PF_SYSTEM, AF_SYSTEM, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, + SOCK_SEQPACKET, SOCK_RDM, SO_DEBUG, SO_ACCEPTCONN, SO_REUSEADDR, + SO_KEEPALIVE, SO_DONTROUTE, SO_BROADCAST, SO_USELOOPBACK, SO_LINGER, + SO_OOBINLINE, SO_REUSEPORT, SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, + SO_RCVLOWAT, SO_SNDTIMEO, SO_RCVTIMEO, SO_ERROR, SO_TYPE, + LOCAL_PEERCRED, SOMAXCONN, SCM_RIGHTS, SCM_CREDS, MSG_OOB, MSG_PEEK, + MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_TRUNC, MSG_CTRUNC, + MSG_WAITALL, MSG_EOF, SOL_SOCKET, SOL_IP, SOL_TCP, SOL_UDP, IPPROTO_IP, + IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_GGP, IPPROTO_IPV4, + IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, IPPROTO_UDP, + IPPROTO_IDP, IPPROTO_HELLO, IPPROTO_ND, IPPROTO_TP, IPPROTO_ROUTING, + IPPROTO_FRAGMENT, IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_ESP, IPPROTO_AH, + IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_DSTOPTS, IPPROTO_XTP, + IPPROTO_EON, IPPROTO_PIM, IPPROTO_IPCOMP, IPPROTO_SCTP, IPPROTO_RAW, + IPPROTO_MAX, SYSPROTO_CONTROL, IPPORT_RESERVED, IPPORT_USERRESERVED, + INADDR_ANY, INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, + INADDR_ALLHOSTS_GROUP, INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, + IP_HDRINCL, IP_TOS, IP_TTL, IP_RECVOPTS, IP_RECVRETOPTS, + IP_RECVDSTADDR, IP_RETOPTS, IP_MULTICAST_IF, IP_MULTICAST_TTL, + IP_MULTICAST_LOOP, IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, + IP_DEFAULT_MULTICAST_TTL, IP_DEFAULT_MULTICAST_LOOP, + IP_MAX_MEMBERSHIPS, IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP, + IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, + IPV6_UNICAST_HOPS, IPV6_V6ONLY, IPV6_CHECKSUM, IPV6_RECVTCLASS, + IPV6_RTHDR_TYPE_0, IPV6_TCLASS, TCP_NODELAY, TCP_MAXSEG, TCP_KEEPINTVL, + TCP_KEEPCNT, TCP_FASTOPEN, EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, + EAI_FAIL, EAI_FAMILY, EAI_MEMORY, EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, + EAI_SERVICE, EAI_SOCKTYPE, EAI_SYSTEM, EAI_BADHINTS, EAI_PROTOCOL, + EAI_MAX, AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST, AI_NUMERICSERV, + AI_MASK, AI_ALL, AI_V4MAPPED_CFG, AI_ADDRCONFIG, AI_V4MAPPED, + AI_DEFAULT, NI_MAXHOST, NI_MAXSERV, NI_NOFQDN, NI_NUMERICHOST, + NI_NAMEREQD, NI_NUMERICSERV, NI_DGRAM, SHUT_RD, SHUT_WR, SHUT_RDWR, + EBADF, EAGAIN, EWOULDBLOCK, _LOCALHOST, _LOCALHOST_V6, + _GLOBAL_DEFAULT_TIMEOUT + ) except ImportError: pass From 9217753eeefedd99a06255cb47f4497eaa2bfe4e Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 02:51:39 +0100 Subject: [PATCH 10/48] Finding the offending symbols 1 --- trio/_socket.py | 74 +++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index 4bc19f9c68..f49b538280 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -3,48 +3,42 @@ from socket import ( gaierror, herror, gethostname, ntohs, htonl, htons, inet_aton, inet_ntoa, inet_pton, inet_ntop, sethostname, if_nameindex, if_nametoindex, - if_indextoname + if_indextoname, CMSG_LEN, CMSG_SPACE, CAPI, AF_UNSPEC, AF_INET, AF_UNIX, + AF_IPX, AF_APPLETALK, AF_INET6, AF_ROUTE, AF_LINK, AF_SNA, PF_SYSTEM, + AF_SYSTEM, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, SOCK_RDM, + SO_DEBUG, SO_ACCEPTCONN, SO_REUSEADDR, SO_KEEPALIVE, SO_DONTROUTE, + SO_BROADCAST, SO_USELOOPBACK, SO_LINGER, SO_OOBINLINE, SO_REUSEPORT, + SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT, SO_SNDTIMEO, SO_RCVTIMEO, + SO_ERROR, SO_TYPE, LOCAL_PEERCRED, SOMAXCONN, SCM_RIGHTS, SCM_CREDS, + MSG_OOB, MSG_PEEK, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_TRUNC, + MSG_CTRUNC, MSG_WAITALL, MSG_EOF, SOL_SOCKET, SOL_IP, SOL_TCP, SOL_UDP, + IPPROTO_IP, IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_GGP, + IPPROTO_IPV4, IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, + IPPROTO_UDP, IPPROTO_IDP, IPPROTO_HELLO, IPPROTO_ND, IPPROTO_TP, + IPPROTO_ROUTING, IPPROTO_FRAGMENT, IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_ESP, + IPPROTO_AH, IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_DSTOPTS, IPPROTO_XTP, + IPPROTO_EON, IPPROTO_PIM, IPPROTO_IPCOMP, IPPROTO_SCTP, IPPROTO_RAW, + IPPROTO_MAX, SYSPROTO_CONTROL, IPPORT_RESERVED, IPPORT_USERRESERVED, + INADDR_ANY, INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, + INADDR_ALLHOSTS_GROUP, INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, + IP_HDRINCL, IP_TOS, IP_TTL, IP_RECVOPTS, IP_RECVRETOPTS, IP_RECVDSTADDR, + IP_RETOPTS, IP_MULTICAST_IF, IP_MULTICAST_TTL, IP_MULTICAST_LOOP, + IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_DEFAULT_MULTICAST_TTL, + IP_DEFAULT_MULTICAST_LOOP, IP_MAX_MEMBERSHIPS, IPV6_JOIN_GROUP, + IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, + IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY, IPV6_CHECKSUM, + IPV6_RECVTCLASS, IPV6_RTHDR_TYPE_0, IPV6_TCLASS, TCP_NODELAY, TCP_MAXSEG, + TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN, EAI_ADDRFAMILY, EAI_AGAIN, + EAI_BADFLAGS, EAI_FAIL, EAI_FAMILY, EAI_MEMORY, EAI_NODATA, EAI_NONAME, + EAI_OVERFLOW, EAI_SERVICE, EAI_SOCKTYPE, EAI_SYSTEM, EAI_BADHINTS, + EAI_PROTOCOL, EAI_MAX, AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST, + AI_NUMERICSERV, AI_MASK, AI_ALL, AI_V4MAPPED_CFG, AI_ADDRCONFIG, + AI_V4MAPPED, AI_DEFAULT, NI_MAXHOST, NI_MAXSERV, NI_NOFQDN, NI_NUMERICHOST, + NI_NAMEREQD, NI_NUMERICSERV, NI_DGRAM, SHUT_RD, SHUT_WR, SHUT_RDWR, EBADF, + EAGAIN, EWOULDBLOCK, _LOCALHOST, _LOCALHOST_V6, _GLOBAL_DEFAULT_TIMEOUT ) - try: - from socket import ( - IPPROTO_IPV6, TCP_NOTSENT_LOWAT, CMSG_LEN, CMSG_SPACE, CAPI, AF_UNSPEC, - AF_INET, AF_UNIX, AF_IPX, AF_APPLETALK, AF_INET6, AF_ROUTE, AF_LINK, - AF_SNA, PF_SYSTEM, AF_SYSTEM, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, - SOCK_SEQPACKET, SOCK_RDM, SO_DEBUG, SO_ACCEPTCONN, SO_REUSEADDR, - SO_KEEPALIVE, SO_DONTROUTE, SO_BROADCAST, SO_USELOOPBACK, SO_LINGER, - SO_OOBINLINE, SO_REUSEPORT, SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, - SO_RCVLOWAT, SO_SNDTIMEO, SO_RCVTIMEO, SO_ERROR, SO_TYPE, - LOCAL_PEERCRED, SOMAXCONN, SCM_RIGHTS, SCM_CREDS, MSG_OOB, MSG_PEEK, - MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_TRUNC, MSG_CTRUNC, - MSG_WAITALL, MSG_EOF, SOL_SOCKET, SOL_IP, SOL_TCP, SOL_UDP, IPPROTO_IP, - IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_GGP, IPPROTO_IPV4, - IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, IPPROTO_UDP, - IPPROTO_IDP, IPPROTO_HELLO, IPPROTO_ND, IPPROTO_TP, IPPROTO_ROUTING, - IPPROTO_FRAGMENT, IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_ESP, IPPROTO_AH, - IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_DSTOPTS, IPPROTO_XTP, - IPPROTO_EON, IPPROTO_PIM, IPPROTO_IPCOMP, IPPROTO_SCTP, IPPROTO_RAW, - IPPROTO_MAX, SYSPROTO_CONTROL, IPPORT_RESERVED, IPPORT_USERRESERVED, - INADDR_ANY, INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, - INADDR_ALLHOSTS_GROUP, INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, - IP_HDRINCL, IP_TOS, IP_TTL, IP_RECVOPTS, IP_RECVRETOPTS, - IP_RECVDSTADDR, IP_RETOPTS, IP_MULTICAST_IF, IP_MULTICAST_TTL, - IP_MULTICAST_LOOP, IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, - IP_DEFAULT_MULTICAST_TTL, IP_DEFAULT_MULTICAST_LOOP, - IP_MAX_MEMBERSHIPS, IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP, - IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, - IPV6_UNICAST_HOPS, IPV6_V6ONLY, IPV6_CHECKSUM, IPV6_RECVTCLASS, - IPV6_RTHDR_TYPE_0, IPV6_TCLASS, TCP_NODELAY, TCP_MAXSEG, TCP_KEEPINTVL, - TCP_KEEPCNT, TCP_FASTOPEN, EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, - EAI_FAIL, EAI_FAMILY, EAI_MEMORY, EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, - EAI_SERVICE, EAI_SOCKTYPE, EAI_SYSTEM, EAI_BADHINTS, EAI_PROTOCOL, - EAI_MAX, AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST, AI_NUMERICSERV, - AI_MASK, AI_ALL, AI_V4MAPPED_CFG, AI_ADDRCONFIG, AI_V4MAPPED, - AI_DEFAULT, NI_MAXHOST, NI_MAXSERV, NI_NOFQDN, NI_NUMERICHOST, - NI_NAMEREQD, NI_NUMERICSERV, NI_DGRAM, SHUT_RD, SHUT_WR, SHUT_RDWR, - EBADF, EAGAIN, EWOULDBLOCK, _LOCALHOST, _LOCALHOST_V6, - _GLOBAL_DEFAULT_TIMEOUT - ) + from socket import (IPPROTO_IPV6, TCP_NOTSENT_LOWAT) except ImportError: pass From 1f0159984bf407fdfd92f3df5fcd2690cd601f4f Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 02:58:17 +0100 Subject: [PATCH 11/48] Added new name IPPROTO_SCTP to import --- trio/_socket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trio/_socket.py b/trio/_socket.py index f49b538280..c8e09623a5 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -38,7 +38,7 @@ EAGAIN, EWOULDBLOCK, _LOCALHOST, _LOCALHOST_V6, _GLOBAL_DEFAULT_TIMEOUT ) try: - from socket import (IPPROTO_IPV6, TCP_NOTSENT_LOWAT) + from socket import (IPPROTO_IPV6, IPPROTO_SCTP, TCP_NOTSENT_LOWAT) except ImportError: pass From b764a97710b6c7392266e2108383715cba9e0c76 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 03:02:52 +0100 Subject: [PATCH 12/48] Moved new name IPPROTO_SCTP to try except block --- trio/_socket.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index c8e09623a5..43c73cb53d 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -17,9 +17,9 @@ IPPROTO_UDP, IPPROTO_IDP, IPPROTO_HELLO, IPPROTO_ND, IPPROTO_TP, IPPROTO_ROUTING, IPPROTO_FRAGMENT, IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_ESP, IPPROTO_AH, IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_DSTOPTS, IPPROTO_XTP, - IPPROTO_EON, IPPROTO_PIM, IPPROTO_IPCOMP, IPPROTO_SCTP, IPPROTO_RAW, - IPPROTO_MAX, SYSPROTO_CONTROL, IPPORT_RESERVED, IPPORT_USERRESERVED, - INADDR_ANY, INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, + IPPROTO_EON, IPPROTO_PIM, IPPROTO_IPCOMP, IPPROTO_RAW, IPPROTO_MAX, + SYSPROTO_CONTROL, IPPORT_RESERVED, IPPORT_USERRESERVED, INADDR_ANY, + INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, INADDR_ALLHOSTS_GROUP, INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, IP_HDRINCL, IP_TOS, IP_TTL, IP_RECVOPTS, IP_RECVRETOPTS, IP_RECVDSTADDR, IP_RETOPTS, IP_MULTICAST_IF, IP_MULTICAST_TTL, IP_MULTICAST_LOOP, From 7118f9ba775c3004690aad082941715a863698d6 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 03:08:20 +0100 Subject: [PATCH 13/48] Moved new name TCP_KEEPINTVL to try except block --- trio/_socket.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index 43c73cb53d..7bc91cfb5a 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -28,17 +28,19 @@ IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY, IPV6_CHECKSUM, IPV6_RECVTCLASS, IPV6_RTHDR_TYPE_0, IPV6_TCLASS, TCP_NODELAY, TCP_MAXSEG, - TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN, EAI_ADDRFAMILY, EAI_AGAIN, - EAI_BADFLAGS, EAI_FAIL, EAI_FAMILY, EAI_MEMORY, EAI_NODATA, EAI_NONAME, - EAI_OVERFLOW, EAI_SERVICE, EAI_SOCKTYPE, EAI_SYSTEM, EAI_BADHINTS, - EAI_PROTOCOL, EAI_MAX, AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST, - AI_NUMERICSERV, AI_MASK, AI_ALL, AI_V4MAPPED_CFG, AI_ADDRCONFIG, - AI_V4MAPPED, AI_DEFAULT, NI_MAXHOST, NI_MAXSERV, NI_NOFQDN, NI_NUMERICHOST, - NI_NAMEREQD, NI_NUMERICSERV, NI_DGRAM, SHUT_RD, SHUT_WR, SHUT_RDWR, EBADF, - EAGAIN, EWOULDBLOCK, _LOCALHOST, _LOCALHOST_V6, _GLOBAL_DEFAULT_TIMEOUT + TCP_KEEPCNT, TCP_FASTOPEN, EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, + EAI_FAIL, EAI_FAMILY, EAI_MEMORY, EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, + EAI_SERVICE, EAI_SOCKTYPE, EAI_SYSTEM, EAI_BADHINTS, EAI_PROTOCOL, EAI_MAX, + AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST, AI_NUMERICSERV, AI_MASK, AI_ALL, + AI_V4MAPPED_CFG, AI_ADDRCONFIG, AI_V4MAPPED, AI_DEFAULT, NI_MAXHOST, + NI_MAXSERV, NI_NOFQDN, NI_NUMERICHOST, NI_NAMEREQD, NI_NUMERICSERV, + NI_DGRAM, SHUT_RD, SHUT_WR, SHUT_RDWR, EBADF, EAGAIN, EWOULDBLOCK, + _LOCALHOST, _LOCALHOST_V6, _GLOBAL_DEFAULT_TIMEOUT ) try: - from socket import (IPPROTO_IPV6, IPPROTO_SCTP, TCP_NOTSENT_LOWAT) + from socket import ( + IPPROTO_IPV6, IPPROTO_SCTP, TCP_NOTSENT_LOWAT, TCP_KEEPINTVL + ) except ImportError: pass From 6c93661269a62acab8bc0cae44e10046b28e9665 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 03:12:11 +0100 Subject: [PATCH 14/48] Moved new name TCP_KEEPCNT to try except block --- trio/_socket.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index 7bc91cfb5a..d82048b88e 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -28,10 +28,10 @@ IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY, IPV6_CHECKSUM, IPV6_RECVTCLASS, IPV6_RTHDR_TYPE_0, IPV6_TCLASS, TCP_NODELAY, TCP_MAXSEG, - TCP_KEEPCNT, TCP_FASTOPEN, EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, - EAI_FAIL, EAI_FAMILY, EAI_MEMORY, EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, - EAI_SERVICE, EAI_SOCKTYPE, EAI_SYSTEM, EAI_BADHINTS, EAI_PROTOCOL, EAI_MAX, - AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST, AI_NUMERICSERV, AI_MASK, AI_ALL, + TCP_FASTOPEN, EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, EAI_FAIL, + EAI_FAMILY, EAI_MEMORY, EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, EAI_SERVICE, + EAI_SOCKTYPE, EAI_SYSTEM, EAI_BADHINTS, EAI_PROTOCOL, EAI_MAX, AI_PASSIVE, + AI_CANONNAME, AI_NUMERICHOST, AI_NUMERICSERV, AI_MASK, AI_ALL, AI_V4MAPPED_CFG, AI_ADDRCONFIG, AI_V4MAPPED, AI_DEFAULT, NI_MAXHOST, NI_MAXSERV, NI_NOFQDN, NI_NUMERICHOST, NI_NAMEREQD, NI_NUMERICSERV, NI_DGRAM, SHUT_RD, SHUT_WR, SHUT_RDWR, EBADF, EAGAIN, EWOULDBLOCK, @@ -39,7 +39,8 @@ ) try: from socket import ( - IPPROTO_IPV6, IPPROTO_SCTP, TCP_NOTSENT_LOWAT, TCP_KEEPINTVL + IPPROTO_IPV6, IPPROTO_SCTP, TCP_NOTSENT_LOWAT, TCP_KEEPINTVL, + TCP_KEEPCNT ) except ImportError: pass From 37afde1badb3dba00c029e4a132e016f660b4d37 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 03:15:22 +0100 Subject: [PATCH 15/48] Moved new name TCP_FASTOPEN to try except block --- trio/_socket.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index d82048b88e..cf6bd0ac27 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -28,19 +28,19 @@ IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY, IPV6_CHECKSUM, IPV6_RECVTCLASS, IPV6_RTHDR_TYPE_0, IPV6_TCLASS, TCP_NODELAY, TCP_MAXSEG, - TCP_FASTOPEN, EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, EAI_FAIL, - EAI_FAMILY, EAI_MEMORY, EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, EAI_SERVICE, - EAI_SOCKTYPE, EAI_SYSTEM, EAI_BADHINTS, EAI_PROTOCOL, EAI_MAX, AI_PASSIVE, - AI_CANONNAME, AI_NUMERICHOST, AI_NUMERICSERV, AI_MASK, AI_ALL, - AI_V4MAPPED_CFG, AI_ADDRCONFIG, AI_V4MAPPED, AI_DEFAULT, NI_MAXHOST, - NI_MAXSERV, NI_NOFQDN, NI_NUMERICHOST, NI_NAMEREQD, NI_NUMERICSERV, - NI_DGRAM, SHUT_RD, SHUT_WR, SHUT_RDWR, EBADF, EAGAIN, EWOULDBLOCK, - _LOCALHOST, _LOCALHOST_V6, _GLOBAL_DEFAULT_TIMEOUT + EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, EAI_FAIL, EAI_FAMILY, EAI_MEMORY, + EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, EAI_SERVICE, EAI_SOCKTYPE, + EAI_SYSTEM, EAI_BADHINTS, EAI_PROTOCOL, EAI_MAX, AI_PASSIVE, AI_CANONNAME, + AI_NUMERICHOST, AI_NUMERICSERV, AI_MASK, AI_ALL, AI_V4MAPPED_CFG, + AI_ADDRCONFIG, AI_V4MAPPED, AI_DEFAULT, NI_MAXHOST, NI_MAXSERV, NI_NOFQDN, + NI_NUMERICHOST, NI_NAMEREQD, NI_NUMERICSERV, NI_DGRAM, SHUT_RD, SHUT_WR, + SHUT_RDWR, EBADF, EAGAIN, EWOULDBLOCK, _LOCALHOST, _LOCALHOST_V6, + _GLOBAL_DEFAULT_TIMEOUT ) try: from socket import ( IPPROTO_IPV6, IPPROTO_SCTP, TCP_NOTSENT_LOWAT, TCP_KEEPINTVL, - TCP_KEEPCNT + TCP_KEEPCNT, TCP_FASTOPEN ) except ImportError: pass From 1e438e3c76729a4c4ce2ee1a99420142faa96d4c Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 03:31:48 +0100 Subject: [PATCH 16/48] Moved new name AF_LINK to try except block --- trio/_socket.py | 65 ++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index cf6bd0ac27..c149673841 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -4,42 +4,41 @@ gaierror, herror, gethostname, ntohs, htonl, htons, inet_aton, inet_ntoa, inet_pton, inet_ntop, sethostname, if_nameindex, if_nametoindex, if_indextoname, CMSG_LEN, CMSG_SPACE, CAPI, AF_UNSPEC, AF_INET, AF_UNIX, - AF_IPX, AF_APPLETALK, AF_INET6, AF_ROUTE, AF_LINK, AF_SNA, PF_SYSTEM, - AF_SYSTEM, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, SOCK_RDM, - SO_DEBUG, SO_ACCEPTCONN, SO_REUSEADDR, SO_KEEPALIVE, SO_DONTROUTE, - SO_BROADCAST, SO_USELOOPBACK, SO_LINGER, SO_OOBINLINE, SO_REUSEPORT, - SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT, SO_SNDTIMEO, SO_RCVTIMEO, - SO_ERROR, SO_TYPE, LOCAL_PEERCRED, SOMAXCONN, SCM_RIGHTS, SCM_CREDS, - MSG_OOB, MSG_PEEK, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_TRUNC, - MSG_CTRUNC, MSG_WAITALL, MSG_EOF, SOL_SOCKET, SOL_IP, SOL_TCP, SOL_UDP, - IPPROTO_IP, IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_GGP, - IPPROTO_IPV4, IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, - IPPROTO_UDP, IPPROTO_IDP, IPPROTO_HELLO, IPPROTO_ND, IPPROTO_TP, - IPPROTO_ROUTING, IPPROTO_FRAGMENT, IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_ESP, - IPPROTO_AH, IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_DSTOPTS, IPPROTO_XTP, - IPPROTO_EON, IPPROTO_PIM, IPPROTO_IPCOMP, IPPROTO_RAW, IPPROTO_MAX, - SYSPROTO_CONTROL, IPPORT_RESERVED, IPPORT_USERRESERVED, INADDR_ANY, - INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, - INADDR_ALLHOSTS_GROUP, INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, - IP_HDRINCL, IP_TOS, IP_TTL, IP_RECVOPTS, IP_RECVRETOPTS, IP_RECVDSTADDR, - IP_RETOPTS, IP_MULTICAST_IF, IP_MULTICAST_TTL, IP_MULTICAST_LOOP, - IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_DEFAULT_MULTICAST_TTL, - IP_DEFAULT_MULTICAST_LOOP, IP_MAX_MEMBERSHIPS, IPV6_JOIN_GROUP, - IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, - IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY, IPV6_CHECKSUM, - IPV6_RECVTCLASS, IPV6_RTHDR_TYPE_0, IPV6_TCLASS, TCP_NODELAY, TCP_MAXSEG, - EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, EAI_FAIL, EAI_FAMILY, EAI_MEMORY, - EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, EAI_SERVICE, EAI_SOCKTYPE, - EAI_SYSTEM, EAI_BADHINTS, EAI_PROTOCOL, EAI_MAX, AI_PASSIVE, AI_CANONNAME, - AI_NUMERICHOST, AI_NUMERICSERV, AI_MASK, AI_ALL, AI_V4MAPPED_CFG, - AI_ADDRCONFIG, AI_V4MAPPED, AI_DEFAULT, NI_MAXHOST, NI_MAXSERV, NI_NOFQDN, - NI_NUMERICHOST, NI_NAMEREQD, NI_NUMERICSERV, NI_DGRAM, SHUT_RD, SHUT_WR, - SHUT_RDWR, EBADF, EAGAIN, EWOULDBLOCK, _LOCALHOST, _LOCALHOST_V6, - _GLOBAL_DEFAULT_TIMEOUT + AF_IPX, AF_APPLETALK, AF_INET6, AF_ROUTE, AF_SNA, PF_SYSTEM, AF_SYSTEM, + SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, SOCK_RDM, SO_DEBUG, + SO_ACCEPTCONN, SO_REUSEADDR, SO_KEEPALIVE, SO_DONTROUTE, SO_BROADCAST, + SO_USELOOPBACK, SO_LINGER, SO_OOBINLINE, SO_REUSEPORT, SO_SNDBUF, + SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT, SO_SNDTIMEO, SO_RCVTIMEO, SO_ERROR, + SO_TYPE, LOCAL_PEERCRED, SOMAXCONN, SCM_RIGHTS, SCM_CREDS, MSG_OOB, + MSG_PEEK, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_TRUNC, MSG_CTRUNC, + MSG_WAITALL, MSG_EOF, SOL_SOCKET, SOL_IP, SOL_TCP, SOL_UDP, IPPROTO_IP, + IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_GGP, IPPROTO_IPV4, + IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, IPPROTO_UDP, + IPPROTO_IDP, IPPROTO_HELLO, IPPROTO_ND, IPPROTO_TP, IPPROTO_ROUTING, + IPPROTO_FRAGMENT, IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_ESP, IPPROTO_AH, + IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_DSTOPTS, IPPROTO_XTP, IPPROTO_EON, + IPPROTO_PIM, IPPROTO_IPCOMP, IPPROTO_RAW, IPPROTO_MAX, SYSPROTO_CONTROL, + IPPORT_RESERVED, IPPORT_USERRESERVED, INADDR_ANY, INADDR_BROADCAST, + INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, INADDR_ALLHOSTS_GROUP, + INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, IP_HDRINCL, IP_TOS, + IP_TTL, IP_RECVOPTS, IP_RECVRETOPTS, IP_RECVDSTADDR, IP_RETOPTS, + IP_MULTICAST_IF, IP_MULTICAST_TTL, IP_MULTICAST_LOOP, IP_ADD_MEMBERSHIP, + IP_DROP_MEMBERSHIP, IP_DEFAULT_MULTICAST_TTL, IP_DEFAULT_MULTICAST_LOOP, + IP_MAX_MEMBERSHIPS, IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS, + IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY, + IPV6_CHECKSUM, IPV6_RECVTCLASS, IPV6_RTHDR_TYPE_0, IPV6_TCLASS, + TCP_NODELAY, TCP_MAXSEG, EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, EAI_FAIL, + EAI_FAMILY, EAI_MEMORY, EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, EAI_SERVICE, + EAI_SOCKTYPE, EAI_SYSTEM, EAI_BADHINTS, EAI_PROTOCOL, EAI_MAX, AI_PASSIVE, + AI_CANONNAME, AI_NUMERICHOST, AI_NUMERICSERV, AI_MASK, AI_ALL, + AI_V4MAPPED_CFG, AI_ADDRCONFIG, AI_V4MAPPED, AI_DEFAULT, NI_MAXHOST, + NI_MAXSERV, NI_NOFQDN, NI_NUMERICHOST, NI_NAMEREQD, NI_NUMERICSERV, + NI_DGRAM, SHUT_RD, SHUT_WR, SHUT_RDWR, EBADF, EAGAIN, EWOULDBLOCK, + _LOCALHOST, _LOCALHOST_V6, _GLOBAL_DEFAULT_TIMEOUT ) try: from socket import ( - IPPROTO_IPV6, IPPROTO_SCTP, TCP_NOTSENT_LOWAT, TCP_KEEPINTVL, + AF_LINK, IPPROTO_IPV6, IPPROTO_SCTP, TCP_NOTSENT_LOWAT, TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN ) except ImportError: From 305db2d5b328e5013b851351fcc9cac0a881e409 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 03:37:25 +0100 Subject: [PATCH 17/48] Moved new name sethostname to try except block --- trio/_signals.py | 2 +- trio/_socket.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/trio/_signals.py b/trio/_signals.py index 9010c420cb..3b910a92d1 100644 --- a/trio/_signals.py +++ b/trio/_signals.py @@ -177,7 +177,7 @@ def __aiter__(self): return self async def __anext__(self): - return {await self._signal_queue.__anext__()} + return { await self._signal_queue.__anext__()} @deprecated("0.7.0", issue=354, instead=open_signal_receiver) diff --git a/trio/_socket.py b/trio/_socket.py index c149673841..ab0e56f7d0 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -2,9 +2,9 @@ import socket as _stdlib_socket from socket import ( gaierror, herror, gethostname, ntohs, htonl, htons, inet_aton, inet_ntoa, - inet_pton, inet_ntop, sethostname, if_nameindex, if_nametoindex, - if_indextoname, CMSG_LEN, CMSG_SPACE, CAPI, AF_UNSPEC, AF_INET, AF_UNIX, - AF_IPX, AF_APPLETALK, AF_INET6, AF_ROUTE, AF_SNA, PF_SYSTEM, AF_SYSTEM, + inet_pton, inet_ntop, if_nameindex, if_nametoindex, if_indextoname, + CMSG_LEN, CMSG_SPACE, CAPI, AF_UNSPEC, AF_INET, AF_UNIX, AF_IPX, + AF_APPLETALK, AF_INET6, AF_ROUTE, AF_SNA, PF_SYSTEM, AF_SYSTEM, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, SOCK_RDM, SO_DEBUG, SO_ACCEPTCONN, SO_REUSEADDR, SO_KEEPALIVE, SO_DONTROUTE, SO_BROADCAST, SO_USELOOPBACK, SO_LINGER, SO_OOBINLINE, SO_REUSEPORT, SO_SNDBUF, @@ -38,8 +38,8 @@ ) try: from socket import ( - AF_LINK, IPPROTO_IPV6, IPPROTO_SCTP, TCP_NOTSENT_LOWAT, TCP_KEEPINTVL, - TCP_KEEPCNT, TCP_FASTOPEN + sethostname, AF_LINK, IPPROTO_IPV6, IPPROTO_SCTP, TCP_NOTSENT_LOWAT, + TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN ) except ImportError: pass From f7fe91b61929b7b0657981261213fe61f4e3d30c Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 03:48:32 +0100 Subject: [PATCH 18/48] Moved new name PF_SYSTEM to try except block --- trio/_socket.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index ab0e56f7d0..1a3ed4a537 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -4,20 +4,20 @@ gaierror, herror, gethostname, ntohs, htonl, htons, inet_aton, inet_ntoa, inet_pton, inet_ntop, if_nameindex, if_nametoindex, if_indextoname, CMSG_LEN, CMSG_SPACE, CAPI, AF_UNSPEC, AF_INET, AF_UNIX, AF_IPX, - AF_APPLETALK, AF_INET6, AF_ROUTE, AF_SNA, PF_SYSTEM, AF_SYSTEM, - SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, SOCK_RDM, SO_DEBUG, - SO_ACCEPTCONN, SO_REUSEADDR, SO_KEEPALIVE, SO_DONTROUTE, SO_BROADCAST, - SO_USELOOPBACK, SO_LINGER, SO_OOBINLINE, SO_REUSEPORT, SO_SNDBUF, - SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT, SO_SNDTIMEO, SO_RCVTIMEO, SO_ERROR, - SO_TYPE, LOCAL_PEERCRED, SOMAXCONN, SCM_RIGHTS, SCM_CREDS, MSG_OOB, - MSG_PEEK, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_TRUNC, MSG_CTRUNC, - MSG_WAITALL, MSG_EOF, SOL_SOCKET, SOL_IP, SOL_TCP, SOL_UDP, IPPROTO_IP, - IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_GGP, IPPROTO_IPV4, - IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, IPPROTO_UDP, - IPPROTO_IDP, IPPROTO_HELLO, IPPROTO_ND, IPPROTO_TP, IPPROTO_ROUTING, - IPPROTO_FRAGMENT, IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_ESP, IPPROTO_AH, - IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_DSTOPTS, IPPROTO_XTP, IPPROTO_EON, - IPPROTO_PIM, IPPROTO_IPCOMP, IPPROTO_RAW, IPPROTO_MAX, SYSPROTO_CONTROL, + AF_APPLETALK, AF_INET6, AF_ROUTE, AF_SNA, AF_SYSTEM, SOCK_STREAM, + SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, SOCK_RDM, SO_DEBUG, SO_ACCEPTCONN, + SO_REUSEADDR, SO_KEEPALIVE, SO_DONTROUTE, SO_BROADCAST, SO_USELOOPBACK, + SO_LINGER, SO_OOBINLINE, SO_REUSEPORT, SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, + SO_RCVLOWAT, SO_SNDTIMEO, SO_RCVTIMEO, SO_ERROR, SO_TYPE, LOCAL_PEERCRED, + SOMAXCONN, SCM_RIGHTS, SCM_CREDS, MSG_OOB, MSG_PEEK, MSG_DONTROUTE, + MSG_DONTWAIT, MSG_EOR, MSG_TRUNC, MSG_CTRUNC, MSG_WAITALL, MSG_EOF, + SOL_SOCKET, SOL_IP, SOL_TCP, SOL_UDP, IPPROTO_IP, IPPROTO_HOPOPTS, + IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_GGP, IPPROTO_IPV4, IPPROTO_IPIP, + IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, IPPROTO_UDP, IPPROTO_IDP, + IPPROTO_HELLO, IPPROTO_ND, IPPROTO_TP, IPPROTO_ROUTING, IPPROTO_FRAGMENT, + IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_ESP, IPPROTO_AH, IPPROTO_ICMPV6, + IPPROTO_NONE, IPPROTO_DSTOPTS, IPPROTO_XTP, IPPROTO_EON, IPPROTO_PIM, + IPPROTO_IPCOMP, IPPROTO_RAW, IPPROTO_MAX, SYSPROTO_CONTROL, IPPORT_RESERVED, IPPORT_USERRESERVED, INADDR_ANY, INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, INADDR_ALLHOSTS_GROUP, INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, IP_HDRINCL, IP_TOS, @@ -38,8 +38,8 @@ ) try: from socket import ( - sethostname, AF_LINK, IPPROTO_IPV6, IPPROTO_SCTP, TCP_NOTSENT_LOWAT, - TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN + sethostname, AF_LINK, IPPROTO_IPV6, IPPROTO_SCTP, PF_SYSTEM, + TCP_NOTSENT_LOWAT, TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN ) except ImportError: pass From fc3095120359e6fb3db81bf6adf2d6f0648e9eaa Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 04:02:16 +0100 Subject: [PATCH 19/48] Moved new name AF_SYSTEM to try except block --- trio/_socket.py | 71 +++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index 1a3ed4a537..ee4b7d5cab 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -2,44 +2,45 @@ import socket as _stdlib_socket from socket import ( gaierror, herror, gethostname, ntohs, htonl, htons, inet_aton, inet_ntoa, - inet_pton, inet_ntop, if_nameindex, if_nametoindex, if_indextoname, - CMSG_LEN, CMSG_SPACE, CAPI, AF_UNSPEC, AF_INET, AF_UNIX, AF_IPX, - AF_APPLETALK, AF_INET6, AF_ROUTE, AF_SNA, AF_SYSTEM, SOCK_STREAM, - SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, SOCK_RDM, SO_DEBUG, SO_ACCEPTCONN, - SO_REUSEADDR, SO_KEEPALIVE, SO_DONTROUTE, SO_BROADCAST, SO_USELOOPBACK, - SO_LINGER, SO_OOBINLINE, SO_REUSEPORT, SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, - SO_RCVLOWAT, SO_SNDTIMEO, SO_RCVTIMEO, SO_ERROR, SO_TYPE, LOCAL_PEERCRED, - SOMAXCONN, SCM_RIGHTS, SCM_CREDS, MSG_OOB, MSG_PEEK, MSG_DONTROUTE, - MSG_DONTWAIT, MSG_EOR, MSG_TRUNC, MSG_CTRUNC, MSG_WAITALL, MSG_EOF, - SOL_SOCKET, SOL_IP, SOL_TCP, SOL_UDP, IPPROTO_IP, IPPROTO_HOPOPTS, - IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_GGP, IPPROTO_IPV4, IPPROTO_IPIP, - IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, IPPROTO_UDP, IPPROTO_IDP, - IPPROTO_HELLO, IPPROTO_ND, IPPROTO_TP, IPPROTO_ROUTING, IPPROTO_FRAGMENT, - IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_ESP, IPPROTO_AH, IPPROTO_ICMPV6, - IPPROTO_NONE, IPPROTO_DSTOPTS, IPPROTO_XTP, IPPROTO_EON, IPPROTO_PIM, - IPPROTO_IPCOMP, IPPROTO_RAW, IPPROTO_MAX, SYSPROTO_CONTROL, - IPPORT_RESERVED, IPPORT_USERRESERVED, INADDR_ANY, INADDR_BROADCAST, - INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, INADDR_ALLHOSTS_GROUP, - INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, IP_HDRINCL, IP_TOS, - IP_TTL, IP_RECVOPTS, IP_RECVRETOPTS, IP_RECVDSTADDR, IP_RETOPTS, - IP_MULTICAST_IF, IP_MULTICAST_TTL, IP_MULTICAST_LOOP, IP_ADD_MEMBERSHIP, - IP_DROP_MEMBERSHIP, IP_DEFAULT_MULTICAST_TTL, IP_DEFAULT_MULTICAST_LOOP, - IP_MAX_MEMBERSHIPS, IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS, - IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY, - IPV6_CHECKSUM, IPV6_RECVTCLASS, IPV6_RTHDR_TYPE_0, IPV6_TCLASS, - TCP_NODELAY, TCP_MAXSEG, EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, EAI_FAIL, - EAI_FAMILY, EAI_MEMORY, EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, EAI_SERVICE, - EAI_SOCKTYPE, EAI_SYSTEM, EAI_BADHINTS, EAI_PROTOCOL, EAI_MAX, AI_PASSIVE, - AI_CANONNAME, AI_NUMERICHOST, AI_NUMERICSERV, AI_MASK, AI_ALL, - AI_V4MAPPED_CFG, AI_ADDRCONFIG, AI_V4MAPPED, AI_DEFAULT, NI_MAXHOST, - NI_MAXSERV, NI_NOFQDN, NI_NUMERICHOST, NI_NAMEREQD, NI_NUMERICSERV, - NI_DGRAM, SHUT_RD, SHUT_WR, SHUT_RDWR, EBADF, EAGAIN, EWOULDBLOCK, - _LOCALHOST, _LOCALHOST_V6, _GLOBAL_DEFAULT_TIMEOUT + inet_pton, inet_ntop, if_nametoindex, if_indextoname, CMSG_LEN, CMSG_SPACE, + CAPI, AF_UNSPEC, AF_INET, AF_UNIX, AF_IPX, AF_APPLETALK, AF_INET6, + AF_ROUTE, AF_SNA, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, + SOCK_RDM, SO_DEBUG, SO_ACCEPTCONN, SO_REUSEADDR, SO_KEEPALIVE, + SO_DONTROUTE, SO_BROADCAST, SO_USELOOPBACK, SO_LINGER, SO_OOBINLINE, + SO_REUSEPORT, SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT, SO_SNDTIMEO, + SO_RCVTIMEO, SO_ERROR, SO_TYPE, LOCAL_PEERCRED, SOMAXCONN, SCM_RIGHTS, + SCM_CREDS, MSG_OOB, MSG_PEEK, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, + MSG_TRUNC, MSG_CTRUNC, MSG_WAITALL, MSG_EOF, SOL_SOCKET, SOL_IP, SOL_TCP, + SOL_UDP, IPPROTO_IP, IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_IGMP, + IPPROTO_GGP, IPPROTO_IPV4, IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, + IPPROTO_PUP, IPPROTO_UDP, IPPROTO_IDP, IPPROTO_HELLO, IPPROTO_ND, + IPPROTO_TP, IPPROTO_ROUTING, IPPROTO_FRAGMENT, IPPROTO_RSVP, IPPROTO_GRE, + IPPROTO_ESP, IPPROTO_AH, IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_DSTOPTS, + IPPROTO_XTP, IPPROTO_EON, IPPROTO_PIM, IPPROTO_IPCOMP, IPPROTO_RAW, + IPPROTO_MAX, SYSPROTO_CONTROL, IPPORT_RESERVED, IPPORT_USERRESERVED, + INADDR_ANY, INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, + INADDR_ALLHOSTS_GROUP, INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, + IP_HDRINCL, IP_TOS, IP_TTL, IP_RECVOPTS, IP_RECVRETOPTS, IP_RECVDSTADDR, + IP_RETOPTS, IP_MULTICAST_IF, IP_MULTICAST_TTL, IP_MULTICAST_LOOP, + IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_DEFAULT_MULTICAST_TTL, + IP_DEFAULT_MULTICAST_LOOP, IP_MAX_MEMBERSHIPS, IPV6_JOIN_GROUP, + IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, + IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY, IPV6_CHECKSUM, + IPV6_RECVTCLASS, IPV6_RTHDR_TYPE_0, IPV6_TCLASS, TCP_NODELAY, TCP_MAXSEG, + EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, EAI_FAIL, EAI_FAMILY, EAI_MEMORY, + EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, EAI_SERVICE, EAI_SOCKTYPE, + EAI_SYSTEM, EAI_BADHINTS, EAI_PROTOCOL, EAI_MAX, AI_PASSIVE, AI_CANONNAME, + AI_NUMERICHOST, AI_NUMERICSERV, AI_MASK, AI_ALL, AI_V4MAPPED_CFG, + AI_ADDRCONFIG, AI_V4MAPPED, AI_DEFAULT, NI_MAXHOST, NI_MAXSERV, NI_NOFQDN, + NI_NUMERICHOST, NI_NAMEREQD, NI_NUMERICSERV, NI_DGRAM, SHUT_RD, SHUT_WR, + SHUT_RDWR, EBADF, EAGAIN, EWOULDBLOCK, _LOCALHOST, _LOCALHOST_V6, + _GLOBAL_DEFAULT_TIMEOUT ) try: from socket import ( - sethostname, AF_LINK, IPPROTO_IPV6, IPPROTO_SCTP, PF_SYSTEM, - TCP_NOTSENT_LOWAT, TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN + if_nameindex, sethostname, AF_LINK, AF_SYSTEM, IPPROTO_IPV6, + IPPROTO_SCTP, PF_SYSTEM, TCP_NOTSENT_LOWAT, TCP_KEEPINTVL, TCP_KEEPCNT, + TCP_FASTOPEN ) except ImportError: pass From 97bc5a83940794f473582e16107d4170073aed19 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 08:10:07 +0100 Subject: [PATCH 20/48] Moved new name SO_USELOOPBACK to try except block --- trio/_socket.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index ee4b7d5cab..e29162b1dd 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -6,19 +6,19 @@ CAPI, AF_UNSPEC, AF_INET, AF_UNIX, AF_IPX, AF_APPLETALK, AF_INET6, AF_ROUTE, AF_SNA, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, SOCK_RDM, SO_DEBUG, SO_ACCEPTCONN, SO_REUSEADDR, SO_KEEPALIVE, - SO_DONTROUTE, SO_BROADCAST, SO_USELOOPBACK, SO_LINGER, SO_OOBINLINE, - SO_REUSEPORT, SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT, SO_SNDTIMEO, - SO_RCVTIMEO, SO_ERROR, SO_TYPE, LOCAL_PEERCRED, SOMAXCONN, SCM_RIGHTS, - SCM_CREDS, MSG_OOB, MSG_PEEK, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, - MSG_TRUNC, MSG_CTRUNC, MSG_WAITALL, MSG_EOF, SOL_SOCKET, SOL_IP, SOL_TCP, - SOL_UDP, IPPROTO_IP, IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_IGMP, - IPPROTO_GGP, IPPROTO_IPV4, IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, - IPPROTO_PUP, IPPROTO_UDP, IPPROTO_IDP, IPPROTO_HELLO, IPPROTO_ND, - IPPROTO_TP, IPPROTO_ROUTING, IPPROTO_FRAGMENT, IPPROTO_RSVP, IPPROTO_GRE, - IPPROTO_ESP, IPPROTO_AH, IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_DSTOPTS, - IPPROTO_XTP, IPPROTO_EON, IPPROTO_PIM, IPPROTO_IPCOMP, IPPROTO_RAW, - IPPROTO_MAX, SYSPROTO_CONTROL, IPPORT_RESERVED, IPPORT_USERRESERVED, - INADDR_ANY, INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, + SO_DONTROUTE, SO_BROADCAST, SO_LINGER, SO_OOBINLINE, SO_REUSEPORT, + SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT, SO_SNDTIMEO, SO_RCVTIMEO, + SO_ERROR, SO_TYPE, LOCAL_PEERCRED, SOMAXCONN, SCM_RIGHTS, SCM_CREDS, + MSG_OOB, MSG_PEEK, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_TRUNC, + MSG_CTRUNC, MSG_WAITALL, MSG_EOF, SOL_SOCKET, SOL_IP, SOL_TCP, SOL_UDP, + IPPROTO_IP, IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_GGP, + IPPROTO_IPV4, IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, + IPPROTO_UDP, IPPROTO_IDP, IPPROTO_HELLO, IPPROTO_ND, IPPROTO_TP, + IPPROTO_ROUTING, IPPROTO_FRAGMENT, IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_ESP, + IPPROTO_AH, IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_DSTOPTS, IPPROTO_XTP, + IPPROTO_EON, IPPROTO_PIM, IPPROTO_IPCOMP, IPPROTO_RAW, IPPROTO_MAX, + SYSPROTO_CONTROL, IPPORT_RESERVED, IPPORT_USERRESERVED, INADDR_ANY, + INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, INADDR_ALLHOSTS_GROUP, INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, IP_HDRINCL, IP_TOS, IP_TTL, IP_RECVOPTS, IP_RECVRETOPTS, IP_RECVDSTADDR, IP_RETOPTS, IP_MULTICAST_IF, IP_MULTICAST_TTL, IP_MULTICAST_LOOP, @@ -39,8 +39,8 @@ try: from socket import ( if_nameindex, sethostname, AF_LINK, AF_SYSTEM, IPPROTO_IPV6, - IPPROTO_SCTP, PF_SYSTEM, TCP_NOTSENT_LOWAT, TCP_KEEPINTVL, TCP_KEEPCNT, - TCP_FASTOPEN + IPPROTO_SCTP, PF_SYSTEM, SO_USELOOPBACK, TCP_NOTSENT_LOWAT, + TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN ) except ImportError: pass From ecdcdf233c3e9d0956e4ff514ddeaabdf3d66e7a Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 09:55:03 +0100 Subject: [PATCH 21/48] Put all namespaces in a try except block and pull out the once that are needed --- trio/_socket.py | 86 +++++++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index e29162b1dd..ae14deb2fa 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -1,50 +1,58 @@ import os as _os import socket as _stdlib_socket -from socket import ( - gaierror, herror, gethostname, ntohs, htonl, htons, inet_aton, inet_ntoa, - inet_pton, inet_ntop, if_nametoindex, if_indextoname, CMSG_LEN, CMSG_SPACE, - CAPI, AF_UNSPEC, AF_INET, AF_UNIX, AF_IPX, AF_APPLETALK, AF_INET6, - AF_ROUTE, AF_SNA, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, - SOCK_RDM, SO_DEBUG, SO_ACCEPTCONN, SO_REUSEADDR, SO_KEEPALIVE, - SO_DONTROUTE, SO_BROADCAST, SO_LINGER, SO_OOBINLINE, SO_REUSEPORT, - SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT, SO_SNDTIMEO, SO_RCVTIMEO, - SO_ERROR, SO_TYPE, LOCAL_PEERCRED, SOMAXCONN, SCM_RIGHTS, SCM_CREDS, - MSG_OOB, MSG_PEEK, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_TRUNC, - MSG_CTRUNC, MSG_WAITALL, MSG_EOF, SOL_SOCKET, SOL_IP, SOL_TCP, SOL_UDP, - IPPROTO_IP, IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_GGP, - IPPROTO_IPV4, IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, - IPPROTO_UDP, IPPROTO_IDP, IPPROTO_HELLO, IPPROTO_ND, IPPROTO_TP, - IPPROTO_ROUTING, IPPROTO_FRAGMENT, IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_ESP, - IPPROTO_AH, IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_DSTOPTS, IPPROTO_XTP, - IPPROTO_EON, IPPROTO_PIM, IPPROTO_IPCOMP, IPPROTO_RAW, IPPROTO_MAX, - SYSPROTO_CONTROL, IPPORT_RESERVED, IPPORT_USERRESERVED, INADDR_ANY, - INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, - INADDR_ALLHOSTS_GROUP, INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, - IP_HDRINCL, IP_TOS, IP_TTL, IP_RECVOPTS, IP_RECVRETOPTS, IP_RECVDSTADDR, - IP_RETOPTS, IP_MULTICAST_IF, IP_MULTICAST_TTL, IP_MULTICAST_LOOP, - IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_DEFAULT_MULTICAST_TTL, - IP_DEFAULT_MULTICAST_LOOP, IP_MAX_MEMBERSHIPS, IPV6_JOIN_GROUP, - IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, - IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY, IPV6_CHECKSUM, - IPV6_RECVTCLASS, IPV6_RTHDR_TYPE_0, IPV6_TCLASS, TCP_NODELAY, TCP_MAXSEG, - EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, EAI_FAIL, EAI_FAMILY, EAI_MEMORY, - EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, EAI_SERVICE, EAI_SOCKTYPE, - EAI_SYSTEM, EAI_BADHINTS, EAI_PROTOCOL, EAI_MAX, AI_PASSIVE, AI_CANONNAME, - AI_NUMERICHOST, AI_NUMERICSERV, AI_MASK, AI_ALL, AI_V4MAPPED_CFG, - AI_ADDRCONFIG, AI_V4MAPPED, AI_DEFAULT, NI_MAXHOST, NI_MAXSERV, NI_NOFQDN, - NI_NUMERICHOST, NI_NAMEREQD, NI_NUMERICSERV, NI_DGRAM, SHUT_RD, SHUT_WR, - SHUT_RDWR, EBADF, EAGAIN, EWOULDBLOCK, _LOCALHOST, _LOCALHOST_V6, - _GLOBAL_DEFAULT_TIMEOUT -) + try: from socket import ( - if_nameindex, sethostname, AF_LINK, AF_SYSTEM, IPPROTO_IPV6, - IPPROTO_SCTP, PF_SYSTEM, SO_USELOOPBACK, TCP_NOTSENT_LOWAT, - TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN + gaierror, herror, gethostname, ntohs, htonl, htons, inet_aton, + inet_ntoa, inet_pton, inet_ntop, if_nametoindex, if_indextoname, + CMSG_LEN, CMSG_SPACE, CAPI, AF_UNSPEC, AF_INET, AF_UNIX, AF_IPX, + AF_APPLETALK, AF_INET6, AF_ROUTE, AF_SNA, SOCK_STREAM, SOCK_DGRAM, + SOCK_RAW, SOCK_SEQPACKET, SOCK_RDM, SO_DEBUG, SO_ACCEPTCONN, + SO_REUSEADDR, SO_KEEPALIVE, SO_DONTROUTE, SO_BROADCAST, SO_LINGER, + SO_OOBINLINE, SO_REUSEPORT, SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, + SO_RCVLOWAT, SO_SNDTIMEO, SO_RCVTIMEO, SO_ERROR, SO_TYPE, SOMAXCONN, + SCM_RIGHTS, SCM_CREDS, MSG_OOB, MSG_PEEK, MSG_DONTROUTE, MSG_DONTWAIT, + MSG_EOR, MSG_TRUNC, MSG_CTRUNC, MSG_WAITALL, MSG_EOF, SOL_SOCKET, + SOL_IP, SOL_TCP, SOL_UDP, IPPROTO_IP, IPPROTO_HOPOPTS, IPPROTO_ICMP, + IPPROTO_IGMP, IPPROTO_GGP, IPPROTO_IPV4, IPPROTO_IPIP, IPPROTO_TCP, + IPPROTO_EGP, IPPROTO_PUP, IPPROTO_UDP, IPPROTO_IDP, IPPROTO_HELLO, + IPPROTO_ND, IPPROTO_TP, IPPROTO_ROUTING, IPPROTO_FRAGMENT, + IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_ESP, IPPROTO_AH, IPPROTO_ICMPV6, + IPPROTO_NONE, IPPROTO_DSTOPTS, IPPROTO_XTP, IPPROTO_EON, IPPROTO_PIM, + IPPROTO_IPCOMP, IPPROTO_RAW, IPPROTO_MAX, SYSPROTO_CONTROL, + IPPORT_RESERVED, IPPORT_USERRESERVED, INADDR_ANY, INADDR_BROADCAST, + INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, INADDR_ALLHOSTS_GROUP, + INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, IP_HDRINCL, IP_TOS, + IP_TTL, IP_RECVOPTS, IP_RECVRETOPTS, IP_RECVDSTADDR, IP_RETOPTS, + IP_MULTICAST_IF, IP_MULTICAST_TTL, IP_MULTICAST_LOOP, + IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_DEFAULT_MULTICAST_TTL, + IP_DEFAULT_MULTICAST_LOOP, IP_MAX_MEMBERSHIPS, IPV6_JOIN_GROUP, + IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, + IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY, IPV6_CHECKSUM, + IPV6_RECVTCLASS, IPV6_RTHDR_TYPE_0, IPV6_TCLASS, TCP_NODELAY, + TCP_MAXSEG, EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, EAI_FAIL, + EAI_FAMILY, EAI_MEMORY, EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, + EAI_SERVICE, EAI_SOCKTYPE, EAI_SYSTEM, EAI_BADHINTS, EAI_PROTOCOL, + EAI_MAX, AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST, AI_NUMERICSERV, + AI_MASK, AI_ALL, AI_V4MAPPED_CFG, AI_ADDRCONFIG, AI_V4MAPPED, + AI_DEFAULT, NI_MAXHOST, NI_MAXSERV, NI_NOFQDN, NI_NUMERICHOST, + NI_NAMEREQD, NI_NUMERICSERV, NI_DGRAM, SHUT_RD, SHUT_WR, SHUT_RDWR, + EBADF, EAGAIN, EWOULDBLOCK, _LOCALHOST, _LOCALHOST_V6, + _GLOBAL_DEFAULT_TIMEOUT, if_nameindex, sethostname, AF_LINK, AF_SYSTEM, + IPPROTO_IPV6, IPPROTO_SCTP, LOCAL_PEERCRED, PF_SYSTEM, SO_USELOOPBACK, + TCP_NOTSENT_LOWAT, TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN ) + except ImportError: pass +# try: +# from socket import ( +# if_nameindex, sethostname, AF_LINK, AF_SYSTEM, IPPROTO_IPV6, +# IPPROTO_SCTP, LOCAL_PEERCRED, PF_SYSTEM, SO_USELOOPBACK, TCP_NOTSENT_LOWAT, +# TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN +# ) + import sys as _sys from functools import wraps as _wraps From 638ab9a9a2ded8c4b49ab10f0f800bd48fc771b9 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 10:16:39 +0100 Subject: [PATCH 22/48] Pull out SOCK_STREAM --- trio/_socket.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index ae14deb2fa..54a860a1dc 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -1,19 +1,24 @@ import os as _os import socket as _stdlib_socket +try: + from socket import (SOCK_STREAM) +except ImportError: + pass + try: from socket import ( gaierror, herror, gethostname, ntohs, htonl, htons, inet_aton, inet_ntoa, inet_pton, inet_ntop, if_nametoindex, if_indextoname, CMSG_LEN, CMSG_SPACE, CAPI, AF_UNSPEC, AF_INET, AF_UNIX, AF_IPX, - AF_APPLETALK, AF_INET6, AF_ROUTE, AF_SNA, SOCK_STREAM, SOCK_DGRAM, - SOCK_RAW, SOCK_SEQPACKET, SOCK_RDM, SO_DEBUG, SO_ACCEPTCONN, - SO_REUSEADDR, SO_KEEPALIVE, SO_DONTROUTE, SO_BROADCAST, SO_LINGER, - SO_OOBINLINE, SO_REUSEPORT, SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, - SO_RCVLOWAT, SO_SNDTIMEO, SO_RCVTIMEO, SO_ERROR, SO_TYPE, SOMAXCONN, - SCM_RIGHTS, SCM_CREDS, MSG_OOB, MSG_PEEK, MSG_DONTROUTE, MSG_DONTWAIT, - MSG_EOR, MSG_TRUNC, MSG_CTRUNC, MSG_WAITALL, MSG_EOF, SOL_SOCKET, - SOL_IP, SOL_TCP, SOL_UDP, IPPROTO_IP, IPPROTO_HOPOPTS, IPPROTO_ICMP, + AF_APPLETALK, AF_INET6, AF_ROUTE, AF_SNA, SOCK_DGRAM, SOCK_RAW, + SOCK_SEQPACKET, SOCK_RDM, SO_DEBUG, SO_ACCEPTCONN, SO_REUSEADDR, + SO_KEEPALIVE, SO_DONTROUTE, SO_BROADCAST, SO_LINGER, SO_OOBINLINE, + SO_REUSEPORT, SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT, + SO_SNDTIMEO, SO_RCVTIMEO, SO_ERROR, SO_TYPE, SOMAXCONN, SCM_RIGHTS, + SCM_CREDS, MSG_OOB, MSG_PEEK, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, + MSG_TRUNC, MSG_CTRUNC, MSG_WAITALL, MSG_EOF, SOL_SOCKET, SOL_IP, + SOL_TCP, SOL_UDP, IPPROTO_IP, IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_GGP, IPPROTO_IPV4, IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, IPPROTO_UDP, IPPROTO_IDP, IPPROTO_HELLO, IPPROTO_ND, IPPROTO_TP, IPPROTO_ROUTING, IPPROTO_FRAGMENT, @@ -39,8 +44,8 @@ NI_NAMEREQD, NI_NUMERICSERV, NI_DGRAM, SHUT_RD, SHUT_WR, SHUT_RDWR, EBADF, EAGAIN, EWOULDBLOCK, _LOCALHOST, _LOCALHOST_V6, _GLOBAL_DEFAULT_TIMEOUT, if_nameindex, sethostname, AF_LINK, AF_SYSTEM, - IPPROTO_IPV6, IPPROTO_SCTP, LOCAL_PEERCRED, PF_SYSTEM, SO_USELOOPBACK, - TCP_NOTSENT_LOWAT, TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN + IPPROTO_SCTP, LOCAL_PEERCRED, PF_SYSTEM, SO_USELOOPBACK, TCP_KEEPINTVL, + TCP_KEEPCNT, TCP_FASTOPEN ) except ImportError: From 94042ce750bccefd5fedd779612fe82506f7a6b6 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 10:28:56 +0100 Subject: [PATCH 23/48] Fixed typo in IPPROTO_IPV6 name --- trio/_socket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trio/_socket.py b/trio/_socket.py index 54a860a1dc..77122da7f0 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -115,7 +115,7 @@ async def __aexit__(self, etype, value, tb): # https://bugs.python.org/issue29515 if not hasattr(_stdlib_socket, "IPPROTO_IPV6"): # pragma: no branch IPPROTO_IPV6 = 41 - globals()['IPPPROTO_IPV6'] = IPPROTO_IPV6 + globals()['IPPROTO_IPV6'] = IPPROTO_IPV6 ################################################################ # Overrides From 583570dc17899e6c5cfdd0eac659ef562615393a Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 11:49:11 +0100 Subject: [PATCH 24/48] Fixed missing import on non win platforms of IPPROTO_IPV6 --- trio/_socket.py | 124 ++++++++++++++++++++++++++---------------------- 1 file changed, 67 insertions(+), 57 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index 77122da7f0..3083c560df 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -1,5 +1,42 @@ import os as _os import socket as _stdlib_socket +import sys as _sys +from functools import wraps as _wraps + +import idna as _idna + +from . import _core +from ._threads import run_sync_in_worker_thread +from ._util import fspath + + +class _try_sync: + def __init__(self, blocking_exc_override=None): + self._blocking_exc_override = blocking_exc_override + + def _is_blocking_io_error(self, exc): + if self._blocking_exc_override is None: + return isinstance(exc, BlockingIOError) + else: + return self._blocking_exc_override(exc) + + async def __aenter__(self): + await _core.checkpoint_if_cancelled() + + async def __aexit__(self, etype, value, tb): + if value is not None and self._is_blocking_io_error(value): + # Discard the exception and fall through to the code below the + # block + return True + else: + await _core.cancel_shielded_checkpoint() + # Let the return or exception propagate + return False + + +################################################################ +# CONSTANTS +################################################################ try: from socket import (SOCK_STREAM) @@ -12,7 +49,7 @@ inet_ntoa, inet_pton, inet_ntop, if_nametoindex, if_indextoname, CMSG_LEN, CMSG_SPACE, CAPI, AF_UNSPEC, AF_INET, AF_UNIX, AF_IPX, AF_APPLETALK, AF_INET6, AF_ROUTE, AF_SNA, SOCK_DGRAM, SOCK_RAW, - SOCK_SEQPACKET, SOCK_RDM, SO_DEBUG, SO_ACCEPTCONN, SO_REUSEADDR, + SOCK_SEQPACKET, SOCK_RDM, SO_DEBUG, SO_ACCEPTCONN, SO_KEEPALIVE, SO_DONTROUTE, SO_BROADCAST, SO_LINGER, SO_OOBINLINE, SO_REUSEPORT, SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT, SO_SNDTIMEO, SO_RCVTIMEO, SO_ERROR, SO_TYPE, SOMAXCONN, SCM_RIGHTS, @@ -48,57 +85,23 @@ TCP_KEEPCNT, TCP_FASTOPEN ) -except ImportError: - pass - -# try: -# from socket import ( -# if_nameindex, sethostname, AF_LINK, AF_SYSTEM, IPPROTO_IPV6, -# IPPROTO_SCTP, LOCAL_PEERCRED, PF_SYSTEM, SO_USELOOPBACK, TCP_NOTSENT_LOWAT, -# TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN -# ) +except ImportError as exp: + print(exp) -import sys as _sys -from functools import wraps as _wraps - -import idna as _idna - -from . import _core -from ._threads import run_sync_in_worker_thread -from ._util import fspath - - -class _try_sync: - def __init__(self, blocking_exc_override=None): - self._blocking_exc_override = blocking_exc_override - - def _is_blocking_io_error(self, exc): - if self._blocking_exc_override is None: - return isinstance(exc, BlockingIOError) - else: - return self._blocking_exc_override(exc) - - async def __aenter__(self): - await _core.checkpoint_if_cancelled() - - async def __aexit__(self, etype, value, tb): - if value is not None and self._is_blocking_io_error(value): - # Discard the exception and fall through to the code below the - # block - return True - else: - await _core.cancel_shielded_checkpoint() - # Let the return or exception propagate - return False - - -################################################################ -# CONSTANTS -################################################################ +try: + from socket import IPPROTO_IPV6 +except ImportError: + # As of at least 3.6, python on Windows is missing IPPROTO_IPV6 + # https://bugs.python.org/issue29515 + if _sys.platform == "win32": # pragma: no branch + IPPROTO_IPV6 = 41 + globals()['IPPROTO_IPV6'] = IPPROTO_IPV6 -# Hopefully will show up in 3.7: -# https://github.com/python/cpython/pull/477 -if not hasattr(_stdlib_socket, "TCP_NOTSENT_LOWAT"): # pragma: no branch +try: + from socket import TCP_NOTSENT_LOWAT +except ImportError: + # Hopefully will show up in 3.7: + # https://github.com/python/cpython/pull/477 if _sys.platform == "darwin": TCP_NOTSENT_LOWAT = 0x201 globals()['TCP_NOTSENT_LOWAT'] = TCP_NOTSENT_LOWAT @@ -106,16 +109,23 @@ async def __aexit__(self, etype, value, tb): TCP_NOTSENT_LOWAT = 25 globals()['TCP_NOTSENT_LOWAT'] = TCP_NOTSENT_LOWAT -if _sys.platform == "win32": +if _sys.platform != "win32": # See https://github.com/python-trio/trio/issues/39 + # Do not import for windows platform # (you can still get it from stdlib socket, of course, if you want it) - del SO_REUSEADDR + try: + from socket import SO_REUSEADDR + except ImportError: + pass + +# try: +# from socket import ( +# if_nameindex, sethostname, AF_LINK, AF_SYSTEM, IPPROTO_IPV6, +# IPPROTO_SCTP, LOCAL_PEERCRED, PF_SYSTEM, SO_USELOOPBACK, TCP_NOTSENT_LOWAT, +# TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN +# ) + - # As of at least 3.6, python on Windows is missing IPPROTO_IPV6 - # https://bugs.python.org/issue29515 - if not hasattr(_stdlib_socket, "IPPROTO_IPV6"): # pragma: no branch - IPPROTO_IPV6 = 41 - globals()['IPPROTO_IPV6'] = IPPROTO_IPV6 ################################################################ # Overrides From 6ad0d735b72380e56fdac3ba0cd649eb5912cca4 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 12:03:04 +0100 Subject: [PATCH 25/48] Fixed formatting and missing IPPROTO_SCTP on python 3.8 --- trio/_socket.py | 76 ++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index 3083c560df..66838d7389 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -49,51 +49,53 @@ async def __aexit__(self, etype, value, tb): inet_ntoa, inet_pton, inet_ntop, if_nametoindex, if_indextoname, CMSG_LEN, CMSG_SPACE, CAPI, AF_UNSPEC, AF_INET, AF_UNIX, AF_IPX, AF_APPLETALK, AF_INET6, AF_ROUTE, AF_SNA, SOCK_DGRAM, SOCK_RAW, - SOCK_SEQPACKET, SOCK_RDM, SO_DEBUG, SO_ACCEPTCONN, - SO_KEEPALIVE, SO_DONTROUTE, SO_BROADCAST, SO_LINGER, SO_OOBINLINE, - SO_REUSEPORT, SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT, - SO_SNDTIMEO, SO_RCVTIMEO, SO_ERROR, SO_TYPE, SOMAXCONN, SCM_RIGHTS, - SCM_CREDS, MSG_OOB, MSG_PEEK, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, - MSG_TRUNC, MSG_CTRUNC, MSG_WAITALL, MSG_EOF, SOL_SOCKET, SOL_IP, - SOL_TCP, SOL_UDP, IPPROTO_IP, IPPROTO_HOPOPTS, IPPROTO_ICMP, - IPPROTO_IGMP, IPPROTO_GGP, IPPROTO_IPV4, IPPROTO_IPIP, IPPROTO_TCP, - IPPROTO_EGP, IPPROTO_PUP, IPPROTO_UDP, IPPROTO_IDP, IPPROTO_HELLO, - IPPROTO_ND, IPPROTO_TP, IPPROTO_ROUTING, IPPROTO_FRAGMENT, - IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_ESP, IPPROTO_AH, IPPROTO_ICMPV6, - IPPROTO_NONE, IPPROTO_DSTOPTS, IPPROTO_XTP, IPPROTO_EON, IPPROTO_PIM, - IPPROTO_IPCOMP, IPPROTO_RAW, IPPROTO_MAX, SYSPROTO_CONTROL, - IPPORT_RESERVED, IPPORT_USERRESERVED, INADDR_ANY, INADDR_BROADCAST, - INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, INADDR_ALLHOSTS_GROUP, - INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, IP_HDRINCL, IP_TOS, - IP_TTL, IP_RECVOPTS, IP_RECVRETOPTS, IP_RECVDSTADDR, IP_RETOPTS, - IP_MULTICAST_IF, IP_MULTICAST_TTL, IP_MULTICAST_LOOP, - IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_DEFAULT_MULTICAST_TTL, - IP_DEFAULT_MULTICAST_LOOP, IP_MAX_MEMBERSHIPS, IPV6_JOIN_GROUP, - IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, - IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY, IPV6_CHECKSUM, - IPV6_RECVTCLASS, IPV6_RTHDR_TYPE_0, IPV6_TCLASS, TCP_NODELAY, - TCP_MAXSEG, EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, EAI_FAIL, - EAI_FAMILY, EAI_MEMORY, EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, - EAI_SERVICE, EAI_SOCKTYPE, EAI_SYSTEM, EAI_BADHINTS, EAI_PROTOCOL, - EAI_MAX, AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST, AI_NUMERICSERV, - AI_MASK, AI_ALL, AI_V4MAPPED_CFG, AI_ADDRCONFIG, AI_V4MAPPED, - AI_DEFAULT, NI_MAXHOST, NI_MAXSERV, NI_NOFQDN, NI_NUMERICHOST, - NI_NAMEREQD, NI_NUMERICSERV, NI_DGRAM, SHUT_RD, SHUT_WR, SHUT_RDWR, - EBADF, EAGAIN, EWOULDBLOCK, _LOCALHOST, _LOCALHOST_V6, - _GLOBAL_DEFAULT_TIMEOUT, if_nameindex, sethostname, AF_LINK, AF_SYSTEM, - IPPROTO_SCTP, LOCAL_PEERCRED, PF_SYSTEM, SO_USELOOPBACK, TCP_KEEPINTVL, - TCP_KEEPCNT, TCP_FASTOPEN + SOCK_SEQPACKET, SOCK_RDM, SO_DEBUG, SO_ACCEPTCONN, SO_KEEPALIVE, + SO_DONTROUTE, SO_BROADCAST, SO_LINGER, SO_OOBINLINE, SO_REUSEPORT, + SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT, SO_SNDTIMEO, + SO_RCVTIMEO, SO_ERROR, SO_TYPE, SOMAXCONN, SCM_RIGHTS, SCM_CREDS, + MSG_OOB, MSG_PEEK, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_TRUNC, + MSG_CTRUNC, MSG_WAITALL, MSG_EOF, SOL_SOCKET, SOL_IP, SOL_TCP, SOL_UDP, + IPPROTO_IP, IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_GGP, + IPPROTO_IPV4, IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, + IPPROTO_UDP, IPPROTO_IDP, IPPROTO_HELLO, IPPROTO_ND, IPPROTO_TP, + IPPROTO_ROUTING, IPPROTO_FRAGMENT, IPPROTO_RSVP, IPPROTO_GRE, + IPPROTO_ESP, IPPROTO_AH, IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_DSTOPTS, + IPPROTO_XTP, IPPROTO_EON, IPPROTO_PIM, IPPROTO_IPCOMP, IPPROTO_RAW, + IPPROTO_MAX, SYSPROTO_CONTROL, IPPORT_RESERVED, IPPORT_USERRESERVED, + INADDR_ANY, INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, + INADDR_ALLHOSTS_GROUP, INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, + IP_HDRINCL, IP_TOS, IP_TTL, IP_RECVOPTS, IP_RECVRETOPTS, + IP_RECVDSTADDR, IP_RETOPTS, IP_MULTICAST_IF, IP_MULTICAST_TTL, + IP_MULTICAST_LOOP, IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, + IP_DEFAULT_MULTICAST_TTL, IP_DEFAULT_MULTICAST_LOOP, + IP_MAX_MEMBERSHIPS, IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP, + IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, + IPV6_UNICAST_HOPS, IPV6_V6ONLY, IPV6_CHECKSUM, IPV6_RECVTCLASS, + IPV6_RTHDR_TYPE_0, IPV6_TCLASS, TCP_NODELAY, TCP_MAXSEG, + EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, EAI_FAIL, EAI_FAMILY, + EAI_MEMORY, EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, EAI_SERVICE, + EAI_SOCKTYPE, EAI_SYSTEM, EAI_BADHINTS, EAI_PROTOCOL, EAI_MAX, + AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST, AI_NUMERICSERV, AI_MASK, + AI_ALL, AI_V4MAPPED_CFG, AI_ADDRCONFIG, AI_V4MAPPED, AI_DEFAULT, + NI_MAXHOST, NI_MAXSERV, NI_NOFQDN, NI_NUMERICHOST, NI_NAMEREQD, + NI_NUMERICSERV, NI_DGRAM, SHUT_RD, SHUT_WR, SHUT_RDWR, EBADF, EAGAIN, + EWOULDBLOCK, _LOCALHOST, _LOCALHOST_V6, _GLOBAL_DEFAULT_TIMEOUT, + if_nameindex, sethostname, AF_LINK, AF_SYSTEM, IPPROTO_SCTP, + LOCAL_PEERCRED, PF_SYSTEM, SO_USELOOPBACK, TCP_KEEPINTVL, TCP_KEEPCNT, + TCP_FASTOPEN ) except ImportError as exp: - print(exp) + if _sys.platform == "darwin": + IPPROTO_SCTP = 132 + globals()['IPPROTO_SCTP'] = IPPROTO_SCTP try: from socket import IPPROTO_IPV6 except ImportError: # As of at least 3.6, python on Windows is missing IPPROTO_IPV6 # https://bugs.python.org/issue29515 - if _sys.platform == "win32": # pragma: no branch + if _sys.platform == "win32": # pragma: no branch IPPROTO_IPV6 = 41 globals()['IPPROTO_IPV6'] = IPPROTO_IPV6 @@ -125,8 +127,6 @@ async def __aexit__(self, etype, value, tb): # TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN # ) - - ################################################################ # Overrides ################################################################ From c7d1391e828ec2fb84a57b34688ef6382fe00135 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 19:01:12 +0100 Subject: [PATCH 26/48] Reverted to star import --- trio/_socket.py | 49 +++---------------------------------------------- 1 file changed, 3 insertions(+), 46 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index 66838d7389..ee8c5fd03e 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -38,54 +38,11 @@ async def __aexit__(self, etype, value, tb): # CONSTANTS ################################################################ -try: - from socket import (SOCK_STREAM) -except ImportError: - pass +from socket import * try: - from socket import ( - gaierror, herror, gethostname, ntohs, htonl, htons, inet_aton, - inet_ntoa, inet_pton, inet_ntop, if_nametoindex, if_indextoname, - CMSG_LEN, CMSG_SPACE, CAPI, AF_UNSPEC, AF_INET, AF_UNIX, AF_IPX, - AF_APPLETALK, AF_INET6, AF_ROUTE, AF_SNA, SOCK_DGRAM, SOCK_RAW, - SOCK_SEQPACKET, SOCK_RDM, SO_DEBUG, SO_ACCEPTCONN, SO_KEEPALIVE, - SO_DONTROUTE, SO_BROADCAST, SO_LINGER, SO_OOBINLINE, SO_REUSEPORT, - SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT, SO_SNDTIMEO, - SO_RCVTIMEO, SO_ERROR, SO_TYPE, SOMAXCONN, SCM_RIGHTS, SCM_CREDS, - MSG_OOB, MSG_PEEK, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_TRUNC, - MSG_CTRUNC, MSG_WAITALL, MSG_EOF, SOL_SOCKET, SOL_IP, SOL_TCP, SOL_UDP, - IPPROTO_IP, IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_GGP, - IPPROTO_IPV4, IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, - IPPROTO_UDP, IPPROTO_IDP, IPPROTO_HELLO, IPPROTO_ND, IPPROTO_TP, - IPPROTO_ROUTING, IPPROTO_FRAGMENT, IPPROTO_RSVP, IPPROTO_GRE, - IPPROTO_ESP, IPPROTO_AH, IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_DSTOPTS, - IPPROTO_XTP, IPPROTO_EON, IPPROTO_PIM, IPPROTO_IPCOMP, IPPROTO_RAW, - IPPROTO_MAX, SYSPROTO_CONTROL, IPPORT_RESERVED, IPPORT_USERRESERVED, - INADDR_ANY, INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_UNSPEC_GROUP, - INADDR_ALLHOSTS_GROUP, INADDR_MAX_LOCAL_GROUP, INADDR_NONE, IP_OPTIONS, - IP_HDRINCL, IP_TOS, IP_TTL, IP_RECVOPTS, IP_RECVRETOPTS, - IP_RECVDSTADDR, IP_RETOPTS, IP_MULTICAST_IF, IP_MULTICAST_TTL, - IP_MULTICAST_LOOP, IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, - IP_DEFAULT_MULTICAST_TTL, IP_DEFAULT_MULTICAST_LOOP, - IP_MAX_MEMBERSHIPS, IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP, - IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, - IPV6_UNICAST_HOPS, IPV6_V6ONLY, IPV6_CHECKSUM, IPV6_RECVTCLASS, - IPV6_RTHDR_TYPE_0, IPV6_TCLASS, TCP_NODELAY, TCP_MAXSEG, - EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, EAI_FAIL, EAI_FAMILY, - EAI_MEMORY, EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, EAI_SERVICE, - EAI_SOCKTYPE, EAI_SYSTEM, EAI_BADHINTS, EAI_PROTOCOL, EAI_MAX, - AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST, AI_NUMERICSERV, AI_MASK, - AI_ALL, AI_V4MAPPED_CFG, AI_ADDRCONFIG, AI_V4MAPPED, AI_DEFAULT, - NI_MAXHOST, NI_MAXSERV, NI_NOFQDN, NI_NUMERICHOST, NI_NAMEREQD, - NI_NUMERICSERV, NI_DGRAM, SHUT_RD, SHUT_WR, SHUT_RDWR, EBADF, EAGAIN, - EWOULDBLOCK, _LOCALHOST, _LOCALHOST_V6, _GLOBAL_DEFAULT_TIMEOUT, - if_nameindex, sethostname, AF_LINK, AF_SYSTEM, IPPROTO_SCTP, - LOCAL_PEERCRED, PF_SYSTEM, SO_USELOOPBACK, TCP_KEEPINTVL, TCP_KEEPCNT, - TCP_FASTOPEN - ) - -except ImportError as exp: + from socket import IPPROTO_SCTP +except ImportError: if _sys.platform == "darwin": IPPROTO_SCTP = 132 globals()['IPPROTO_SCTP'] = IPPROTO_SCTP From 7fa93e8c1c422630eda066d1e887e9a35c71719e Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 20:12:08 +0100 Subject: [PATCH 27/48] Removed try except wrap on SO_REUSEADDR --- trio/_socket.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index ee8c5fd03e..67938f9469 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -72,11 +72,8 @@ async def __aexit__(self, etype, value, tb): # See https://github.com/python-trio/trio/issues/39 # Do not import for windows platform # (you can still get it from stdlib socket, of course, if you want it) - try: - from socket import SO_REUSEADDR - except ImportError: - pass - + from socket import SO_REUSEADDR + # try: # from socket import ( # if_nameindex, sethostname, AF_LINK, AF_SYSTEM, IPPROTO_IPV6, From 0c27ae20be2e8c4d64fc6427d9c05b7135f9803b Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 20:13:12 +0100 Subject: [PATCH 28/48] Fixed yapf formatting --- trio/_socket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trio/_socket.py b/trio/_socket.py index 67938f9469..df2de90580 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -73,7 +73,7 @@ async def __aexit__(self, etype, value, tb): # Do not import for windows platform # (you can still get it from stdlib socket, of course, if you want it) from socket import SO_REUSEADDR - + # try: # from socket import ( # if_nameindex, sethostname, AF_LINK, AF_SYSTEM, IPPROTO_IPV6, From f8ce585e1961708a63c70ec9bb8f8ff495227555 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 20:34:58 +0100 Subject: [PATCH 29/48] moved star import to socket.py --- trio/_socket.py | 2 -- trio/socket.py | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index df2de90580..b37279337d 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -38,8 +38,6 @@ async def __aexit__(self, etype, value, tb): # CONSTANTS ################################################################ -from socket import * - try: from socket import IPPROTO_SCTP except ImportError: diff --git a/trio/socket.py b/trio/socket.py index 936811f36d..5e2eef4b1e 100644 --- a/trio/socket.py +++ b/trio/socket.py @@ -4,4 +4,6 @@ # temporaries, imports, etc. when implementing the module. So we put the # implementation in an underscored module, and then re-export the public parts # here. +import sys as _sys +from socket import * from ._socket import * From 762cd8dfdf0c2d96d248ca25a6ba5a63fad14747 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 19 Sep 2018 21:21:09 +0100 Subject: [PATCH 30/48] preparation for dynamic import --- trio/_socket.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/trio/_socket.py b/trio/_socket.py index b37279337d..2d87945314 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -38,6 +38,8 @@ async def __aexit__(self, etype, value, tb): # CONSTANTS ################################################################ + + try: from socket import IPPROTO_SCTP except ImportError: From bc5348477d87341534044170174ac56776ff88ee Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Thu, 20 Sep 2018 04:11:38 +0100 Subject: [PATCH 31/48] Added minimal set of socket constants --- trio/_socket.py | 64 +++++++++++++++++++++++++++++++++---------------- trio/socket.py | 46 ++++++++++++++++++++++++++++++++--- 2 files changed, 86 insertions(+), 24 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index 2d87945314..df683479f2 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -9,6 +9,23 @@ from ._threads import run_sync_in_worker_thread from ._util import fspath +from socket import ( + gaierror, + herror, + gethostname, + ntohs, + htonl, + htons, + inet_aton, + inet_ntoa, + inet_pton, + inet_ntop, + sethostname, + if_nameindex, + if_nametoindex, + if_indextoname, +) + class _try_sync: def __init__(self, blocking_exc_override=None): @@ -38,7 +55,12 @@ async def __aexit__(self, etype, value, tb): # CONSTANTS ################################################################ - +from socket import ( + AF_INET, AF_INET6, IPPROTO_TCP, SOCK_STREAM, SOL_SOCKET, TCP_NODELAY, + AI_CANONNAME, MSG_PEEK, IPV6_V6ONLY, SHUT_WR, SOCK_DGRAM, NI_NUMERICHOST, + AI_PASSIVE, SO_ACCEPTCONN, AF_UNSPEC, SHUT_RD, NI_NUMERICSERV, IPPROTO_UDP, + SHUT_RDWR, EAI_SOCKTYPE, EAI_BADHINTS, AF_UNIX +) try: from socket import IPPROTO_SCTP @@ -335,7 +357,26 @@ def real_socket_type(type_num): return type_num & _SOCK_TYPE_MASK -# @_add_to_all +def _make_simple_sock_method_wrapper(methname, wait_fn, maybe_avail=False): + fn = getattr(_stdlib_socket.socket, methname) + + @_wraps(fn, assigned=("__name__",), updated=()) + async def wrapper(self, *args, **kwargs): + return await self._nonblocking_helper(fn, args, kwargs, wait_fn) + + wrapper.__doc__ = ( + """Like :meth:`socket.socket.{}`, but async. + + """.format(methname) + ) + if maybe_avail: + wrapper.__doc__ += ( + "Only available on platforms where :meth:`socket.socket.{}` " + "is available.".format(methname) + ) + return wrapper + + class SocketType: def __init__(self): raise TypeError( @@ -564,25 +605,6 @@ async def _nonblocking_helper(self, fn, args, kwargs, wait_fn): except BlockingIOError: pass - def _make_simple_sock_method_wrapper(methname, wait_fn, maybe_avail=False): - fn = getattr(_stdlib_socket.socket, methname) - - @_wraps(fn, assigned=("__name__",), updated=()) - async def wrapper(self, *args, **kwargs): - return await self._nonblocking_helper(fn, args, kwargs, wait_fn) - - wrapper.__doc__ = ( - """Like :meth:`socket.socket.{}`, but async. - - """.format(methname) - ) - if maybe_avail: - wrapper.__doc__ += ( - "Only available on platforms where :meth:`socket.socket.{}` " - "is available.".format(methname) - ) - return wrapper - ################################################################ # accept ################################################################ diff --git a/trio/socket.py b/trio/socket.py index 5e2eef4b1e..345cc7925a 100644 --- a/trio/socket.py +++ b/trio/socket.py @@ -4,6 +4,46 @@ # temporaries, imports, etc. when implementing the module. So we put the # implementation in an underscored module, and then re-export the public parts # here. -import sys as _sys -from socket import * -from ._socket import * + +from ._socket import ( + fromfd, from_stdlib_socket, getprotobyname, socketpair, getnameinfo, + socket, getaddrinfo, set_custom_hostname_resolver, + set_custom_socket_factory, real_socket_type, SocketType, fspath, + run_sync_in_worker_thread +) + +try: + from ._socket import fromshare +except ImportError: + pass + +from ._socket import ( + gaierror, + herror, + gethostname, + ntohs, + htonl, + htons, + inet_aton, + inet_ntoa, + inet_pton, + inet_ntop, + sethostname, + if_nameindex, + if_nametoindex, + if_indextoname, +) + +from ._socket import ( + SO_REUSEADDR, IPPROTO_SCTP, IPPROTO_IPV6, TCP_NOTSENT_LOWAT +) +#from ._socket import * + +from ._socket import ( + AF_INET, AF_INET6, IPPROTO_TCP, SOCK_STREAM, SOL_SOCKET, TCP_NODELAY, + AI_CANONNAME, MSG_PEEK, IPV6_V6ONLY, SHUT_WR, SOCK_DGRAM, NI_NUMERICHOST, + AI_PASSIVE, SO_ACCEPTCONN, AF_UNSPEC, SHUT_RD, NI_NUMERICSERV, IPPROTO_UDP, + SHUT_RDWR, EAI_SOCKTYPE, EAI_BADHINTS, AF_UNIX +) + +# from socket import * From ef2309bee32df5a8cb25bbb29051a0d40d46ba19 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Fri, 21 Sep 2018 00:59:33 +0100 Subject: [PATCH 32/48] static import of functions, dynamic of constants --- trio/_socket.py | 21 ++++++++------------- trio/socket.py | 20 ++++++++------------ 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index df683479f2..7a04110eaf 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -1,8 +1,10 @@ import os as _os -import socket as _stdlib_socket import sys as _sys +import importlib as _importlib from functools import wraps as _wraps +_stdlib_socket = _importlib.import_module('socket') + import idna as _idna from . import _core @@ -55,11 +57,11 @@ async def __aexit__(self, etype, value, tb): # CONSTANTS ################################################################ -from socket import ( - AF_INET, AF_INET6, IPPROTO_TCP, SOCK_STREAM, SOL_SOCKET, TCP_NODELAY, - AI_CANONNAME, MSG_PEEK, IPV6_V6ONLY, SHUT_WR, SOCK_DGRAM, NI_NUMERICHOST, - AI_PASSIVE, SO_ACCEPTCONN, AF_UNSPEC, SHUT_RD, NI_NUMERICSERV, IPPROTO_UDP, - SHUT_RDWR, EAI_SOCKTYPE, EAI_BADHINTS, AF_UNIX +globals().update( + { + _name: getattr(_stdlib_socket, _name) + for _name in _stdlib_socket.__dict__ if _name.isupper() + } ) try: @@ -96,13 +98,6 @@ async def __aexit__(self, etype, value, tb): # (you can still get it from stdlib socket, of course, if you want it) from socket import SO_REUSEADDR -# try: -# from socket import ( -# if_nameindex, sethostname, AF_LINK, AF_SYSTEM, IPPROTO_IPV6, -# IPPROTO_SCTP, LOCAL_PEERCRED, PF_SYSTEM, SO_USELOOPBACK, TCP_NOTSENT_LOWAT, -# TCP_KEEPINTVL, TCP_KEEPCNT, TCP_FASTOPEN -# ) - ################################################################ # Overrides ################################################################ diff --git a/trio/socket.py b/trio/socket.py index 345cc7925a..a3dcd2241f 100644 --- a/trio/socket.py +++ b/trio/socket.py @@ -4,6 +4,9 @@ # temporaries, imports, etc. when implementing the module. So we put the # implementation in an underscored module, and then re-export the public parts # here. +import importlib + +_smod = importlib.import_module('._socket', 'trio') from ._socket import ( fromfd, from_stdlib_socket, getprotobyname, socketpair, getnameinfo, @@ -34,16 +37,9 @@ if_indextoname, ) -from ._socket import ( - SO_REUSEADDR, IPPROTO_SCTP, IPPROTO_IPV6, TCP_NOTSENT_LOWAT -) -#from ._socket import * - -from ._socket import ( - AF_INET, AF_INET6, IPPROTO_TCP, SOCK_STREAM, SOL_SOCKET, TCP_NODELAY, - AI_CANONNAME, MSG_PEEK, IPV6_V6ONLY, SHUT_WR, SOCK_DGRAM, NI_NUMERICHOST, - AI_PASSIVE, SO_ACCEPTCONN, AF_UNSPEC, SHUT_RD, NI_NUMERICSERV, IPPROTO_UDP, - SHUT_RDWR, EAI_SOCKTYPE, EAI_BADHINTS, AF_UNIX +globals().update( + { + _name: getattr(_smod, _name) + for _name in _smod.__dict__ if _name.isupper() + } ) - -# from socket import * From ca86946cc18e73e00c0bac4e0a078552552e7d8b Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Fri, 21 Sep 2018 01:21:12 +0100 Subject: [PATCH 33/48] static import of functions, dynamic of constants, fix test failure for sethostname --- trio/_socket.py | 7 ++++++- trio/socket.py | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index 7a04110eaf..4412853529 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -22,12 +22,16 @@ inet_ntoa, inet_pton, inet_ntop, - sethostname, if_nameindex, if_nametoindex, if_indextoname, ) +try: + from socket import sethostname +except ImportError: + pass + class _try_sync: def __init__(self, blocking_exc_override=None): @@ -547,6 +551,7 @@ async def _resolve_address(self, address, flags): # empty list. assert len(gai_res) >= 1 # Address is the last item in the first entry + # normed = gai_res[0][-1] (*_, normed), *_ = gai_res # The above ignored any flowid and scopeid in the passed-in address, # so restore them if present: diff --git a/trio/socket.py b/trio/socket.py index a3dcd2241f..97e98ce7a3 100644 --- a/trio/socket.py +++ b/trio/socket.py @@ -31,12 +31,16 @@ inet_ntoa, inet_pton, inet_ntop, - sethostname, if_nameindex, if_nametoindex, if_indextoname, ) +try: + from socket import sethostname +except ImportError: + pass + globals().update( { _name: getattr(_smod, _name) From 8f066c1adf10990a6e2fe3bbc09045c6f33a150f Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Fri, 21 Sep 2018 01:40:08 +0100 Subject: [PATCH 34/48] static import of functions, dynamic of constants, fix test failure for if_nameindex --- trio/_socket.py | 6 +++++- trio/socket.py | 15 +++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index 4412853529..5d6e00beee 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -22,7 +22,6 @@ inet_ntoa, inet_pton, inet_ntop, - if_nameindex, if_nametoindex, if_indextoname, ) @@ -32,6 +31,11 @@ except ImportError: pass +try: + from socket import if_nameindex +except ImportError: + pass + class _try_sync: def __init__(self, blocking_exc_override=None): diff --git a/trio/socket.py b/trio/socket.py index 97e98ce7a3..5a722844e8 100644 --- a/trio/socket.py +++ b/trio/socket.py @@ -31,19 +31,18 @@ inet_ntoa, inet_pton, inet_ntop, - if_nameindex, if_nametoindex, if_indextoname, ) try: - from socket import sethostname + from ._socket import sethostname except ImportError: pass -globals().update( - { - _name: getattr(_smod, _name) - for _name in _smod.__dict__ if _name.isupper() - } -) +try: + from ._socket import if_nameindex +except ImportError: + pass + +globals().update({_name: getattr(_smod, _name) for _name in _smod.__dict__}) From 0e690f8b220393eff1140a453ddde020938ade51 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Fri, 21 Sep 2018 01:52:11 +0100 Subject: [PATCH 35/48] static import of functions, dynamic of constants, fix test failure for all if_name* --- trio/_socket.py | 11 +++-------- trio/socket.py | 11 +++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index 5d6e00beee..fd138d7093 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -22,17 +22,12 @@ inet_ntoa, inet_pton, inet_ntop, - if_nametoindex, - if_indextoname, ) try: - from socket import sethostname -except ImportError: - pass - -try: - from socket import if_nameindex + from socket import ( + if_nameindexif_nametoindex, if_indextoname, sethostname + ) except ImportError: pass diff --git a/trio/socket.py b/trio/socket.py index 5a722844e8..45396eb957 100644 --- a/trio/socket.py +++ b/trio/socket.py @@ -31,17 +31,12 @@ inet_ntoa, inet_pton, inet_ntop, - if_nametoindex, - if_indextoname, ) try: - from ._socket import sethostname -except ImportError: - pass - -try: - from ._socket import if_nameindex + from ._socket import ( + sethostname, if_nameindexif_nametoindex, if_indextoname + ) except ImportError: pass From 66f5330963b0b05594564de91aa0faaf3af3b2f8 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Fri, 21 Sep 2018 01:54:08 +0100 Subject: [PATCH 36/48] fixed typo --- trio/socket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trio/socket.py b/trio/socket.py index 45396eb957..2ff6efb833 100644 --- a/trio/socket.py +++ b/trio/socket.py @@ -35,7 +35,7 @@ try: from ._socket import ( - sethostname, if_nameindexif_nametoindex, if_indextoname + sethostname, if_nameindex, if_nametoindex, if_indextoname ) except ImportError: pass From 9ac6d342b1d00cc19b890ed8cc3a156aa8261b1e Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Sun, 23 Sep 2018 18:23:00 +0100 Subject: [PATCH 37/48] Moved upper case names import to socket.py and undid prior comment changes. --- trio/_core/_io_windows.py | 4 +-- trio/_socket.py | 53 ++++----------------------------------- trio/socket.py | 48 ++++++++++++++++++++++++++++------- 3 files changed, 46 insertions(+), 59 deletions(-) diff --git a/trio/_core/_io_windows.py b/trio/_core/_io_windows.py index 73d7cc9409..d044b1f0a5 100644 --- a/trio/_core/_io_windows.py +++ b/trio/_core/_io_windows.py @@ -341,8 +341,8 @@ async def _wait_socket(self, which, sock): if sock in self._socket_waiters[which]: await _core.checkpoint() raise _core.ResourceBusyError( - "another task is already waiting to {} this socket". - format(which) + "another task is already waiting to {} this socket" + .format(which) ) self._socket_waiters[which][sock] = _core.current_task() diff --git a/trio/_socket.py b/trio/_socket.py index fd138d7093..784b0c577a 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -1,37 +1,19 @@ import os as _os import sys as _sys -import importlib as _importlib +import socket as _stdlib_socket from functools import wraps as _wraps -_stdlib_socket = _importlib.import_module('socket') - import idna as _idna from . import _core from ._threads import run_sync_in_worker_thread from ._util import fspath -from socket import ( - gaierror, - herror, - gethostname, - ntohs, - htonl, - htons, - inet_aton, - inet_ntoa, - inet_pton, - inet_ntop, -) - -try: - from socket import ( - if_nameindexif_nametoindex, if_indextoname, sethostname - ) -except ImportError: - pass - +# # we only get here if the sync call in fact did fail with a +# # BlockingIOError +# return await do_it_properly_with_a_check_point() +# class _try_sync: def __init__(self, blocking_exc_override=None): self._blocking_exc_override = blocking_exc_override @@ -60,20 +42,6 @@ async def __aexit__(self, etype, value, tb): # CONSTANTS ################################################################ -globals().update( - { - _name: getattr(_stdlib_socket, _name) - for _name in _stdlib_socket.__dict__ if _name.isupper() - } -) - -try: - from socket import IPPROTO_SCTP -except ImportError: - if _sys.platform == "darwin": - IPPROTO_SCTP = 132 - globals()['IPPROTO_SCTP'] = IPPROTO_SCTP - try: from socket import IPPROTO_IPV6 except ImportError: @@ -81,7 +49,6 @@ async def __aexit__(self, etype, value, tb): # https://bugs.python.org/issue29515 if _sys.platform == "win32": # pragma: no branch IPPROTO_IPV6 = 41 - globals()['IPPROTO_IPV6'] = IPPROTO_IPV6 try: from socket import TCP_NOTSENT_LOWAT @@ -90,16 +57,8 @@ async def __aexit__(self, etype, value, tb): # https://github.com/python/cpython/pull/477 if _sys.platform == "darwin": TCP_NOTSENT_LOWAT = 0x201 - globals()['TCP_NOTSENT_LOWAT'] = TCP_NOTSENT_LOWAT elif _sys.platform == "linux": TCP_NOTSENT_LOWAT = 25 - globals()['TCP_NOTSENT_LOWAT'] = TCP_NOTSENT_LOWAT - -if _sys.platform != "win32": - # See https://github.com/python-trio/trio/issues/39 - # Do not import for windows platform - # (you can still get it from stdlib socket, of course, if you want it) - from socket import SO_REUSEADDR ################################################################ # Overrides @@ -293,7 +252,6 @@ def fromfd(*args, **kwargs): if hasattr(_stdlib_socket, "fromshare"): @_wraps(_stdlib_socket.fromshare, assigned=(), updated=()) - # @_add_to_all def fromshare(*args, **kwargs): return from_stdlib_socket(_stdlib_socket.fromshare(*args, **kwargs)) @@ -550,7 +508,6 @@ async def _resolve_address(self, address, flags): # empty list. assert len(gai_res) >= 1 # Address is the last item in the first entry - # normed = gai_res[0][-1] (*_, normed), *_ = gai_res # The above ignored any flowid and scopeid in the passed-in address, # so restore them if present: diff --git a/trio/socket.py b/trio/socket.py index 2ff6efb833..6d21109666 100644 --- a/trio/socket.py +++ b/trio/socket.py @@ -1,26 +1,29 @@ -# This is a public namespace, so we dont want to expose any non-underscored -# attributes that arent actually part of our public API. But its very +# This is a public namespace, so we don't want to expose any non-underscored +# attributes that aren't actually part of our public API. But it's very # annoying to carefully always use underscored names for module-level # temporaries, imports, etc. when implementing the module. So we put the # implementation in an underscored module, and then re-export the public parts # here. -import importlib +# We still have some underscore names though but only a few. -_smod = importlib.import_module('._socket', 'trio') +from . import _socket +import sys as _sys +# import the overwrites from ._socket import ( fromfd, from_stdlib_socket, getprotobyname, socketpair, getnameinfo, socket, getaddrinfo, set_custom_hostname_resolver, - set_custom_socket_factory, real_socket_type, SocketType, fspath, - run_sync_in_worker_thread + set_custom_socket_factory, SocketType, _stdlib_socket ) +# not always available so expose only if try: from ._socket import fromshare except ImportError: pass -from ._socket import ( +# expose these functions to trio.socket +from socket import ( gaierror, herror, gethostname, @@ -33,11 +36,38 @@ inet_ntop, ) +# not always available so expose only if try: - from ._socket import ( + from socket import ( sethostname, if_nameindex, if_nametoindex, if_indextoname ) except ImportError: pass -globals().update({_name: getattr(_smod, _name) for _name in _smod.__dict__}) +# expose all uppercase names from standardlib socket to trio.socket +globals().update( + { + _name: getattr(_stdlib_socket, _name) + for _name in _stdlib_socket.__dict__ if _name.isupper() + } +) + +if _sys.platform == 'win32': + # See https://github.com/python-trio/trio/issues/39 + # Do not import for windows platform + # (you can still get it from stdlib socket, of course, if you want it) + try: + del SO_REUSEADDR + except NameError: + pass + +# get names used by trio that might not be available in all versions +try: + IPPROTO_IPV6 +except NameError: + from ._socket import IPPROTO_IPV6 + +try: + TCP_NOTSENT_LOWAT +except NameError: + from ._socket import TCP_NOTSENT_LOWAT From 7f142f9ce9975b09976afcde5c841b8e04812a47 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Tue, 25 Sep 2018 21:51:43 +0100 Subject: [PATCH 38/48] added newsfragment --- newsfragments/670.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/670.feature.rst diff --git a/newsfragments/670.feature.rst b/newsfragments/670.feature.rst new file mode 100644 index 0000000000..f9701db700 --- /dev/null +++ b/newsfragments/670.feature.rst @@ -0,0 +1 @@ +* Reworked :mod:`trio.socket` namespace construction, making it more understandable by static analysis tools. This should improve tab completion in editors, reduce false positives from pylint, and is another step towards providing type hints. \ No newline at end of file From 39a84f74f8ab210ed645ed3cdcf264dfab8fcd72 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Tue, 25 Sep 2018 21:57:13 +0100 Subject: [PATCH 39/48] Increased pickleshare version to 0.7.5 --- test-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-requirements.txt b/test-requirements.txt index 47144242cb..9d226523c1 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -26,7 +26,7 @@ more-itertools==4.3.0 # via pytest parso==0.3.1 # via jedi pathlib2==2.3.2 # via pytest pexpect==4.6.0 # via ipython -pickleshare==0.7.4 # via ipython +pickleshare==0.7.5 # via ipython pluggy==0.7.1 # via pytest prompt-toolkit==1.0.15 # via ipython ptyprocess==0.6.0 # via pexpect From 245358746ff6e2ddf5dc98475b0c2964801ae0d0 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 26 Sep 2018 06:08:33 +0100 Subject: [PATCH 40/48] Dummy to trigger CI again From f1d45a786cdda745e7525b1ed900ef0a6e7f643c Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 26 Sep 2018 06:28:17 +0100 Subject: [PATCH 41/48] 10 minutes too early try again now From 2ce378d3dd3597022847d9ced06187ed799037f1 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 26 Sep 2018 06:48:55 +0100 Subject: [PATCH 42/48] Do not import TCP_NOTSENT_LOWAT on windows --- trio/socket.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/trio/socket.py b/trio/socket.py index 6d21109666..5390eebaed 100644 --- a/trio/socket.py +++ b/trio/socket.py @@ -70,4 +70,5 @@ try: TCP_NOTSENT_LOWAT except NameError: - from ._socket import TCP_NOTSENT_LOWAT + if _sys.platform != 'win32': + from ._socket import TCP_NOTSENT_LOWAT From caead793b58e4c053912305c4fcf8db001de3d48 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Wed, 26 Sep 2018 18:39:45 +0100 Subject: [PATCH 43/48] unnecessary code removed and definitions moved to from _socket.py to socket.py --- trio/_socket.py | 14 ++++---------- trio/socket.py | 25 +++++++++++++------------ 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/trio/_socket.py b/trio/_socket.py index 784b0c577a..3f3dd6da92 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -10,6 +10,10 @@ from ._util import fspath +# Usage: +# +# async with _try_sync(): +# return sync_call_that_might_fail_with_exception() # # we only get here if the sync call in fact did fail with a # # BlockingIOError # return await do_it_properly_with_a_check_point() @@ -50,16 +54,6 @@ async def __aexit__(self, etype, value, tb): if _sys.platform == "win32": # pragma: no branch IPPROTO_IPV6 = 41 -try: - from socket import TCP_NOTSENT_LOWAT -except ImportError: - # Hopefully will show up in 3.7: - # https://github.com/python/cpython/pull/477 - if _sys.platform == "darwin": - TCP_NOTSENT_LOWAT = 0x201 - elif _sys.platform == "linux": - TCP_NOTSENT_LOWAT = 25 - ################################################################ # Overrides ################################################################ diff --git a/trio/socket.py b/trio/socket.py index 5390eebaed..1ab03234af 100644 --- a/trio/socket.py +++ b/trio/socket.py @@ -13,7 +13,7 @@ from ._socket import ( fromfd, from_stdlib_socket, getprotobyname, socketpair, getnameinfo, socket, getaddrinfo, set_custom_hostname_resolver, - set_custom_socket_factory, SocketType, _stdlib_socket + set_custom_socket_factory, SocketType ) # not always available so expose only if @@ -45,6 +45,8 @@ pass # expose all uppercase names from standardlib socket to trio.socket +import socket as _stdlib_socket + globals().update( { _name: getattr(_stdlib_socket, _name) @@ -56,19 +58,18 @@ # See https://github.com/python-trio/trio/issues/39 # Do not import for windows platform # (you can still get it from stdlib socket, of course, if you want it) - try: - del SO_REUSEADDR - except NameError: - pass + del SO_REUSEADDR -# get names used by trio that might not be available in all versions -try: - IPPROTO_IPV6 -except NameError: - from ._socket import IPPROTO_IPV6 +# get names used by trio that we define on our own +from ._socket import IPPROTO_IPV6 +# Not defined in all python versions and platforms but sometimes needed try: TCP_NOTSENT_LOWAT except NameError: - if _sys.platform != 'win32': - from ._socket import TCP_NOTSENT_LOWAT + # Hopefully will show up in 3.7: + # https://github.com/python/cpython/pull/477 + if _sys.platform == "darwin": + TCP_NOTSENT_LOWAT = 0x201 + elif _sys.platform == "linux": + TCP_NOTSENT_LOWAT = 25 From c43ced7ea1db659f681d1d087f4919fef2d0ffc4 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Thu, 27 Sep 2018 09:33:56 +0100 Subject: [PATCH 44/48] removed pragma comment --- trio/_socket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trio/_socket.py b/trio/_socket.py index 3f3dd6da92..cb0475611f 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -51,7 +51,7 @@ async def __aexit__(self, etype, value, tb): except ImportError: # As of at least 3.6, python on Windows is missing IPPROTO_IPV6 # https://bugs.python.org/issue29515 - if _sys.platform == "win32": # pragma: no branch + if _sys.platform == "win32": IPPROTO_IPV6 = 41 ################################################################ From 3b7cb99fb6e6d27d5a7632b7a69d6b94ba15cb01 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Fri, 28 Sep 2018 08:28:41 +0100 Subject: [PATCH 45/48] New yapf version should fix formatting issues --- trio/_core/_run.py | 8 ++++---- trio/_signals.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/trio/_core/_run.py b/trio/_core/_run.py index f872678933..265068f96c 100644 --- a/trio/_core/_run.py +++ b/trio/_core/_run.py @@ -858,8 +858,8 @@ def _return_value_looks_like_wrong_library(value): "trio was expecting an async function, but instead it got " "{!r} – are you trying to use a library written for " "asyncio/twisted/tornado or similar? That won't work " - "without some sort of compatibility shim.". - format(async_fn) + "without some sort of compatibility shim." + .format(async_fn) ) from None raise @@ -874,8 +874,8 @@ def _return_value_looks_like_wrong_library(value): raise TypeError( "start_soon got unexpected {!r} – are you trying to use a " "library written for asyncio/twisted/tornado or similar? " - "That won't work without some sort of compatibility shim.". - format(coro) + "That won't work without some sort of compatibility shim." + .format(coro) ) if isasyncgen(coro): diff --git a/trio/_signals.py b/trio/_signals.py index 3b910a92d1..9010c420cb 100644 --- a/trio/_signals.py +++ b/trio/_signals.py @@ -177,7 +177,7 @@ def __aiter__(self): return self async def __anext__(self): - return { await self._signal_queue.__anext__()} + return {await self._signal_queue.__anext__()} @deprecated("0.7.0", issue=354, instead=open_signal_receiver) From 9b8dc488114a6da6ea2fdc227ac8ee377d7415dc Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Fri, 28 Sep 2018 08:43:43 +0100 Subject: [PATCH 46/48] Manually adjusted trio/_signals.py formatting --- trio/_signals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trio/_signals.py b/trio/_signals.py index 9010c420cb..3b910a92d1 100644 --- a/trio/_signals.py +++ b/trio/_signals.py @@ -177,7 +177,7 @@ def __aiter__(self): return self async def __anext__(self): - return {await self._signal_queue.__anext__()} + return { await self._signal_queue.__anext__()} @deprecated("0.7.0", issue=354, instead=open_signal_receiver) From 4cf0c77f29b9f39ac3433a7b8ec8561b38a13df1 Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Fri, 28 Sep 2018 10:03:42 +0100 Subject: [PATCH 47/48] Merged newsfragments under a single file --- newsfragments/542.feature.rst | 2 +- newsfragments/670.feature.rst | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 newsfragments/670.feature.rst diff --git a/newsfragments/542.feature.rst b/newsfragments/542.feature.rst index 650b489adc..481234889c 100644 --- a/newsfragments/542.feature.rst +++ b/newsfragments/542.feature.rst @@ -1 +1 @@ -* Reworked :mod:`trio` namespace construction, making it more understandable by static analysis tools. This should improve tab completion in editors, reduce false positives from pylint, and is a first step towards providing type hints. \ No newline at end of file +Reworked :mod:trio, :mod:trio.testing, and :mod:trio.socket namespace construction, making them more understandable by static analysis tools. This should improve tab completion in editors, reduce false positives from pylint, and is a first step towards providing type hints. \ No newline at end of file diff --git a/newsfragments/670.feature.rst b/newsfragments/670.feature.rst deleted file mode 100644 index f9701db700..0000000000 --- a/newsfragments/670.feature.rst +++ /dev/null @@ -1 +0,0 @@ -* Reworked :mod:`trio.socket` namespace construction, making it more understandable by static analysis tools. This should improve tab completion in editors, reduce false positives from pylint, and is another step towards providing type hints. \ No newline at end of file From 59a899d8d3249db013d9c3be047d283c60345cce Mon Sep 17 00:00:00 2001 From: Johannes Maria Frank Date: Fri, 28 Sep 2018 20:24:09 +0100 Subject: [PATCH 48/48] added backticks to module names --- newsfragments/542.feature.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/newsfragments/542.feature.rst b/newsfragments/542.feature.rst index 481234889c..678007c283 100644 --- a/newsfragments/542.feature.rst +++ b/newsfragments/542.feature.rst @@ -1 +1 @@ -Reworked :mod:trio, :mod:trio.testing, and :mod:trio.socket namespace construction, making them more understandable by static analysis tools. This should improve tab completion in editors, reduce false positives from pylint, and is a first step towards providing type hints. \ No newline at end of file +Reworked :mod:`trio`, :mod:`trio.testing`, and :mod:`trio.socket` namespace construction, making them more understandable by static analysis tools. This should improve tab completion in editors, reduce false positives from pylint, and is a first step towards providing type hints. \ No newline at end of file