diff options
-rw-r--r-- | dns/_asyncio_backend.py | 5 | ||||
-rw-r--r-- | dns/_curio_backend.py | 7 | ||||
-rw-r--r-- | dns/_trio_backend.py | 9 |
3 files changed, 12 insertions, 9 deletions
diff --git a/dns/_asyncio_backend.py b/dns/_asyncio_backend.py index f82eb82..4120624 100644 --- a/dns/_asyncio_backend.py +++ b/dns/_asyncio_backend.py @@ -57,7 +57,7 @@ class DatagramSocket(dns._asyncbackend.DatagramSocket): self.transport = transport self.protocol = protocol - async def sendto(self, what, destination, timeout): + async def sendto(self, what, destination, timeout): # pragma: no cover # no timeout for asyncio sendto self.transport.sendto(what, destination) @@ -127,7 +127,8 @@ class Backend(dns._asyncbackend.Backend): server_hostname=server_hostname), timeout) return StreamSocket(af, r, w) - raise NotImplementedError(f'unsupported socket type {socktype}') + raise NotImplementedError('unsupported socket ' + + f'type {socktype}') # pragma: no cover async def sleep(self, interval): await asyncio.sleep(interval) diff --git a/dns/_curio_backend.py b/dns/_curio_backend.py index d5eba68..dca966d 100644 --- a/dns/_curio_backend.py +++ b/dns/_curio_backend.py @@ -30,7 +30,7 @@ class DatagramSocket(dns._asyncbackend.DatagramSocket): async def sendto(self, what, destination, timeout): async with _maybe_timeout(timeout): return await self.socket.sendto(what, destination) - raise dns.exception.Timeout(timeout=timeout) + raise dns.exception.Timeout(timeout=timeout) # pragma: no cover async def recvfrom(self, size, timeout): async with _maybe_timeout(timeout): @@ -78,7 +78,7 @@ class Backend(dns._asyncbackend.Backend): try: if source: s.bind(_lltuple(source, af)) - except Exception: + except Exception: # pragma: no cover await s.close() raise return DatagramSocket(s) @@ -93,7 +93,8 @@ class Backend(dns._asyncbackend.Backend): source_addr=source_addr, server_hostname=server_hostname) return StreamSocket(s) - raise NotImplementedError(f'unsupported socket type {socktype}') + raise NotImplementedError('unsupported socket ' + + f'type {socktype}') # pragma: no cover async def sleep(self, interval): await curio.sleep(interval) diff --git a/dns/_trio_backend.py b/dns/_trio_backend.py index cfb0e1d..0f1378f 100644 --- a/dns/_trio_backend.py +++ b/dns/_trio_backend.py @@ -30,7 +30,7 @@ class DatagramSocket(dns._asyncbackend.DatagramSocket): async def sendto(self, what, destination, timeout): with _maybe_timeout(timeout): return await self.socket.sendto(what, destination) - raise dns.exception.Timeout(timeout=timeout) + raise dns.exception.Timeout(timeout=timeout) # pragma: no cover async def recvfrom(self, size, timeout): with _maybe_timeout(timeout): @@ -85,7 +85,7 @@ class Backend(dns._asyncbackend.Backend): if socktype == socket.SOCK_STREAM: with _maybe_timeout(timeout): await s.connect(_lltuple(destination, af)) - except Exception: + except Exception: # pragma: no cover s.close() raise if socktype == socket.SOCK_DGRAM: @@ -99,11 +99,12 @@ class Backend(dns._asyncbackend.Backend): try: stream = trio.SSLStream(stream, ssl_context, server_hostname=server_hostname) - except Exception: + except Exception: # pragma: no cover await stream.aclose() raise return StreamSocket(af, stream, tls) - raise NotImplementedError(f'unsupported socket type {socktype}') + raise NotImplementedError('unsupported socket ' + + f'type {socktype}') # pragma: no cover async def sleep(self, interval): await trio.sleep(interval) |