]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Remove curio support.
authorBob Halley <halley@dnspython.org>
Sun, 12 Mar 2023 17:03:11 +0000 (10:03 -0700)
committerBob Halley <halley@dnspython.org>
Sun, 12 Mar 2023 17:03:11 +0000 (10:03 -0700)
.github/workflows/python-package.yml
dns/_curio_backend.py [deleted file]
dns/asyncbackend.py
dns/versioned.py
mypy.ini
pyproject.toml
setup.cfg
tests/test_async.py
tests/test_xfr.py

index b42430dd4355ca710d17ef745c8d2a110de1bd61..d81976f93842962bfbe299edd983f553f0f4f3a0 100644 (file)
@@ -44,7 +44,7 @@ jobs:
       run: |
         python -m pip install --upgrade pip
         python -m pip install poetry
-        poetry install -E dnssec -E doh -E idna -E trio -E curio -E doq
+        poetry install -E dnssec -E doh -E idna -E trio -E doq
     - name: Typecheck
       run: |
         poetry run python -m mypy --install-types --non-interactive --disallow-incomplete-defs dns
diff --git a/dns/_curio_backend.py b/dns/_curio_backend.py
deleted file mode 100644 (file)
index 765d647..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-# Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license
-
-"""curio async I/O library query support"""
-
-import socket
-import curio
-import curio.socket  # type: ignore
-
-import dns._asyncbackend
-import dns.exception
-import dns.inet
-
-
-def _maybe_timeout(timeout):
-    if timeout:
-        return curio.ignore_after(timeout)
-    else:
-        return dns._asyncbackend.NullContext()
-
-
-# for brevity
-_lltuple = dns.inet.low_level_address_tuple
-
-# pylint: disable=redefined-outer-name
-
-
-class DatagramSocket(dns._asyncbackend.DatagramSocket):
-    def __init__(self, socket):
-        super().__init__(socket.family)
-        self.socket = socket
-
-    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
-        )  # pragma: no cover  lgtm[py/unreachable-statement]
-
-    async def recvfrom(self, size, timeout):
-        async with _maybe_timeout(timeout):
-            return await self.socket.recvfrom(size)
-        raise dns.exception.Timeout(timeout=timeout)  # lgtm[py/unreachable-statement]
-
-    async def close(self):
-        await self.socket.close()
-
-    async def getpeername(self):
-        return self.socket.getpeername()
-
-    async def getsockname(self):
-        return self.socket.getsockname()
-
-
-class StreamSocket(dns._asyncbackend.StreamSocket):
-    def __init__(self, socket):
-        self.socket = socket
-        self.family = socket.family
-
-    async def sendall(self, what, timeout):
-        async with _maybe_timeout(timeout):
-            return await self.socket.sendall(what)
-        raise dns.exception.Timeout(timeout=timeout)  # lgtm[py/unreachable-statement]
-
-    async def recv(self, size, timeout):
-        async with _maybe_timeout(timeout):
-            return await self.socket.recv(size)
-        raise dns.exception.Timeout(timeout=timeout)  # lgtm[py/unreachable-statement]
-
-    async def close(self):
-        await self.socket.close()
-
-    async def getpeername(self):
-        return self.socket.getpeername()
-
-    async def getsockname(self):
-        return self.socket.getsockname()
-
-
-class Backend(dns._asyncbackend.Backend):
-    def name(self):
-        return "curio"
-
-    async def make_socket(
-        self,
-        af,
-        socktype,
-        proto=0,
-        source=None,
-        destination=None,
-        timeout=None,
-        ssl_context=None,
-        server_hostname=None,
-    ):
-        if socktype == socket.SOCK_DGRAM:
-            s = curio.socket.socket(af, socktype, proto)
-            try:
-                if source:
-                    s.bind(_lltuple(source, af))
-            except Exception:  # pragma: no cover
-                await s.close()
-                raise
-            return DatagramSocket(s)
-        elif socktype == socket.SOCK_STREAM:
-            if source:
-                source_addr = _lltuple(source, af)
-            else:
-                source_addr = None
-            async with _maybe_timeout(timeout):
-                s = await curio.open_connection(
-                    destination[0],
-                    destination[1],
-                    ssl=ssl_context,
-                    source_addr=source_addr,
-                    server_hostname=server_hostname,
-                )
-            return StreamSocket(s)
-        raise NotImplementedError(
-            "unsupported socket " + f"type {socktype}"
-        )  # pragma: no cover
-
-    async def sleep(self, interval):
-        await curio.sleep(interval)
index c7565a99643184e0d0bf2ffbba28bde563d27632..e889ce7b3d967dcd5459289fe4fdb24a479bd245 100644 (file)
@@ -30,8 +30,8 @@ class AsyncLibraryNotFoundError(dns.exception.DNSException):
 def get_backend(name: str) -> Backend:
     """Get the specified asynchronous backend.
 
-    *name*, a ``str``, the name of the backend.  Currently the "trio",
-    "curio", and "asyncio" backends are available.
+    *name*, a ``str``, the name of the backend.  Currently the "trio"
+    and "asyncio" backends are available.
 
     Raises NotImplementError if an unknown backend name is specified.
     """
@@ -43,10 +43,6 @@ def get_backend(name: str) -> Backend:
         import dns._trio_backend
 
         backend = dns._trio_backend.Backend()
-    elif name == "curio":
-        import dns._curio_backend
-
-        backend = dns._curio_backend.Backend()
     elif name == "asyncio":
         import dns._asyncio_backend
 
index 02e24122a86a647d69edf4bbcc8460ec11a82b05..67e1659b52a04902f408b10881e189d66c918f68 100644 (file)
@@ -32,7 +32,6 @@ Transaction = dns.zone.Transaction
 
 
 class Zone(dns.zone.Zone):  # lgtm[py/missing-equals]
-
     __slots__ = [
         "_versions",
         "_versions_lock",
@@ -152,7 +151,7 @@ class Zone(dns.zone.Zone):  # lgtm[py/missing-equals]
             #
             # This is not a problem with Threading module threads as
             # they cannot be canceled, but could be an issue with trio
-            # or curio tasks when we do the async version of writer().
+            # tasks when we do the async version of writer().
             # I.e. we'd need to do something like:
             #
             # try:
index bae974cb7e9ed228227bc4a2cd3fcc0dd2c297af..428f9695f5e230313cd47b6e3b5ee5ef8fecb299 100644 (file)
--- a/mypy.ini
+++ b/mypy.ini
@@ -3,9 +3,6 @@
 [mypy-requests_toolbelt.*]
 ignore_missing_imports = True
 
-[mypy-curio]
-ignore_missing_imports = True
-
 [mypy-trio]
 ignore_missing_imports = True
 
index deb52f7a1d17404ec0f5891f7edc91692e303881..508d11748049f01c8892e858e1ccfd48496d9e87 100644 (file)
@@ -46,7 +46,6 @@ requests = {version="^2.23.0", optional=true}
 idna = {version=">=2.1,<4.0", optional=true}
 cryptography = {version=">=2.6,<40.0", optional=true}
 trio = {version=">=0.14,<0.23", optional=true}
-curio = {version="^1.2", optional=true}
 sniffio = {version="^1.1", optional=true}
 wmi = {version="^1.5.1", optional=true}
 aioquic = {version=">=0.9.20", optional=true}
@@ -68,7 +67,6 @@ doh = ['httpx', 'h2', 'requests', 'requests-toolbelt']
 idna = ['idna']
 dnssec = ['cryptography']
 trio = ['trio']
-curio = ['curio', 'sniffio']
 wmi = ['wmi']
 doq = ['aioquic']
 
index f536eee16a8ddceafa33de5a6497d747fa7a78c7..52325276c12de6d38273512187b1d79e5d21ee16 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -54,7 +54,6 @@ DOH = httpx>=0.21.1; h2>=4.1.0; requests; requests-toolbelt
 IDNA = idna>=2.1
 DNSSEC = cryptography>=2.6
 trio = trio>=0.14.0
-curio = curio>=1.2; sniffio>=1.1
 wmi = wmi>=1.5.1
 DOQ = aioquic>=0.9.20
 
index 52ba2e28c09419d7193a0fc0e08091506595b0de..62f7fc5a190ff2d1cc298fa3524777610cbd9dc8 100644 (file)
@@ -224,7 +224,9 @@ class AsyncTests(unittest.TestCase):
             self.async_run(run4)
 
         async def run5():
-            await dns.asyncresolver.resolve_name(dns.reversename.from_address("8.8.8.8"))
+            await dns.asyncresolver.resolve_name(
+                dns.reversename.from_address("8.8.8.8")
+            )
 
         with self.assertRaises(dns.resolver.NoAnswer):
             self.async_run(run5)
@@ -498,9 +500,6 @@ class AsyncTests(unittest.TestCase):
 
     @unittest.skipIf(not dns.query._have_httpx, "httpx not available")
     def testDOHGetRequest(self):
-        if self.backend.name() == "curio":
-            self.skipTest("anyio dropped curio support")
-
         async def run():
             nameserver_url = random.choice(KNOWN_ANYCAST_DOH_RESOLVER_URLS)
             q = dns.message.make_query("example.com.", dns.rdatatype.A)
@@ -511,9 +510,6 @@ class AsyncTests(unittest.TestCase):
 
     @unittest.skipIf(not dns.query._have_httpx, "httpx not available")
     def testDOHGetRequestHttp1(self):
-        if self.backend.name() == "curio":
-            self.skipTest("anyio dropped curio support")
-
         async def run():
             saved_have_http2 = dns.query._have_http2
             try:
@@ -529,9 +525,6 @@ class AsyncTests(unittest.TestCase):
 
     @unittest.skipIf(not dns.query._have_httpx, "httpx not available")
     def testDOHPostRequest(self):
-        if self.backend.name() == "curio":
-            self.skipTest("anyio dropped curio support")
-
         async def run():
             nameserver_url = random.choice(KNOWN_ANYCAST_DOH_RESOLVER_URLS)
             q = dns.message.make_query("example.com.", dns.rdatatype.A)
@@ -542,9 +535,6 @@ class AsyncTests(unittest.TestCase):
 
     @unittest.skipIf(not dns.query._have_httpx, "httpx not available")
     def testResolverDOH(self):
-        if self.backend.name() == "curio":
-            self.skipTest("anyio dropped curio support")
-
         async def run():
             res = dns.asyncresolver.Resolver(configure=False)
             res.nameservers = ["https://dns.google/dns-query"]
@@ -578,6 +568,7 @@ class AsyncioOnlyTests(unittest.TestCase):
     def testUseAfterTimeout(self):
         if self.connect_udp:
             self.skipTest("test needs connectionless sockets")
+
         # Test #843 fix.
         async def run():
             qname = dns.name.from_text("dns.google")
@@ -638,37 +629,3 @@ try:
 
 except ImportError:
     pass
-
-try:
-    import curio
-    import sniffio
-
-    @unittest.skipIf(sys.platform == "win32", "curio does not work in windows CI")
-    class CurioAsyncDetectionTests(AsyncDetectionTests):
-        sniff_result = "curio"
-
-        def async_run(self, afunc):
-            with curio.Kernel() as kernel:
-                return kernel.run(afunc, shutdown=True)
-
-    @unittest.skipIf(sys.platform == "win32", "curio does not work in windows CI")
-    class CurioNoSniffioAsyncDetectionTests(NoSniffioAsyncDetectionTests):
-        expect_raise = True
-
-        def async_run(self, afunc):
-            with curio.Kernel() as kernel:
-                return kernel.run(afunc, shutdown=True)
-
-    @unittest.skipIf(sys.platform == "win32", "curio does not work in windows CI")
-    class CurioAsyncTests(AsyncTests):
-        connect_udp = False
-
-        def setUp(self):
-            self.backend = dns.asyncbackend.set_default_backend("curio")
-
-        def async_run(self, afunc):
-            with curio.Kernel() as kernel:
-                return kernel.run(afunc, shutdown=True)
-
-except ImportError:
-    pass
index 4893532546bf26cf995734dc917c49edaf0bb900..458cdf9b74f2c71d13715a647a330247d245217a 100644 (file)
@@ -709,24 +709,6 @@ try:
 except ImportError:
     pass
 
-try:
-    import curio
-
-    @pytest.mark.skipif(
-        (not _nanonameserver_available) or sys.platform == "win32",
-        reason="requires nanonameserver or is windows",
-    )
-    def test_curio_inbound_xfr():
-        dns.asyncbackend.set_default_backend("curio")
-
-        async def run():
-            await async_inbound_xfr()
-
-        curio.run(run)
-
-except ImportError:
-    pass
-
 
 class UDPXFRNanoNameserver(Server):
     def __init__(self):