From 96a898feefe213ba2a93f3ed55d82104f1ff2b29 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 21 Jul 2024 09:54:40 -0500 Subject: [PATCH 1/2] Restore AsyncResolver to be the default resolver --- aiohttp/resolver.py | 6 +++--- tests/test_resolver.py | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/aiohttp/resolver.py b/aiohttp/resolver.py index 36a4b98bd64..16abbdec2e9 100644 --- a/aiohttp/resolver.py +++ b/aiohttp/resolver.py @@ -7,16 +7,16 @@ __all__ = ("ThreadedResolver", "AsyncResolver", "DefaultResolver") + try: import aiodns - # aiodns_default = hasattr(aiodns.DNSResolver, 'getaddrinfo') + aiodns_default = hasattr(aiodns.DNSResolver, "getaddrinfo") except ImportError: # pragma: no cover aiodns = None # type: ignore[assignment] + aiodns_default = False -aiodns_default = False - _NUMERIC_SOCKET_FLAGS = socket.AI_NUMERICHOST | socket.AI_NUMERICSERV _SUPPORTS_SCOPE_ID = sys.version_info >= (3, 9, 0) diff --git a/tests/test_resolver.py b/tests/test_resolver.py index ce9f345d737..67e0e915196 100644 --- a/tests/test_resolver.py +++ b/tests/test_resolver.py @@ -311,9 +311,11 @@ async def test_async_resolver_aiodns_not_present(loop: Any, monkeypatch: Any) -> AsyncResolver() -def test_default_resolver() -> None: - # if getaddrinfo: - # assert DefaultResolver is AsyncResolver - # else: - # assert DefaultResolver is ThreadedResolver +@pytest.mark.skipif(not getaddrinfo, reason="aiodns >=3.2.0 required") +def test_aio_dns_is_default() -> None: + assert DefaultResolver is AsyncResolver + + +@pytest.mark.skipif(getaddrinfo, reason="aiodns <3.2.0 required") +def test_threaded_resolver_is_default() -> None: assert DefaultResolver is ThreadedResolver From a4bedcb3aa7bdd8e8189e54e13ccb22b07737fc4 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 21 Jul 2024 10:00:22 -0500 Subject: [PATCH 2/2] changelog --- CHANGES/8522.misc.rst | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CHANGES/8522.misc.rst diff --git a/CHANGES/8522.misc.rst b/CHANGES/8522.misc.rst new file mode 100644 index 00000000000..04f7edcc92d --- /dev/null +++ b/CHANGES/8522.misc.rst @@ -0,0 +1,5 @@ +Restore :py:class:`~aiohttp.resolver.AsyncResolver` to be the default resolver. -- by :user:`bdraco`. + +:py:class:`~aiohttp.resolver.AsyncResolver` was disabled by default because +of IPv6 compatibility issues. These issues have been resolved and +:py:class:`~aiohttp.resolver.AsyncResolver` is again now the default resolver.