{
    "file_diffs": [
        {
            "old_file_content": "",
            "new_file_content": "9451.bugfix.rst",
            "header": {
                "file": {
                    "path": "CHANGES/9455.bugfix.rst"
                },
                "misc_line": "new file mode 120000"
            },
            "index_line": {
                "old_commit_hash": "00000000",
                "new_commit_hash": "da8457a1",
                "mode": ""
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "/dev/null"
            },
            "plus_file": {
                "path": "b/CHANGES/9455.bugfix.rst"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 0,
                            "length": 0
                        },
                        "new_range": {
                            "start": 1,
                            "length": null
                        },
                        "section": ""
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "9451.bugfix.rst",
                                "type": "added"
                            },
                            {
                                "content": "No newline at end of file",
                                "type": "note"
                            }
                        ]
                    },
                    "modified_entities": [],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "import asyncio\nimport socket\nimport sys\nfrom typing import Any, Dict, List, Optional, Tuple, Type, Union\n\nfrom .abc import AbstractResolver, ResolveResult\n\n__all__ = (\"ThreadedResolver\", \"AsyncResolver\", \"DefaultResolver\")\n\n\ntry:\n    import aiodns\n\n    aiodns_default = hasattr(aiodns.DNSResolver, \"getaddrinfo\")\nexcept ImportError:  # pragma: no cover\n    aiodns = None  # type: ignore[assignment]\n    aiodns_default = False\n\n\n_NUMERIC_SOCKET_FLAGS = socket.AI_NUMERICHOST | socket.AI_NUMERICSERV\n_NAME_SOCKET_FLAGS = socket.NI_NUMERICHOST | socket.NI_NUMERICSERV\n_SUPPORTS_SCOPE_ID = sys.version_info >= (3, 9, 0)\n\n\nclass ThreadedResolver(AbstractResolver):\n    \"\"\"Threaded resolver.\n\n    Uses an Executor for synchronous getaddrinfo() calls.\n    concurrent.futures.ThreadPoolExecutor is used by default.\n    \"\"\"\n\n    def __init__(self, loop: Optional[asyncio.AbstractEventLoop] = None) -> None:\n        self._loop = loop or asyncio.get_running_loop()\n\n    async def resolve(\n        self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET\n    ) -> List[ResolveResult]:\n        infos = await self._loop.getaddrinfo(\n            host,\n            port,\n            type=socket.SOCK_STREAM,\n            family=family,\n            flags=socket.AI_ADDRCONFIG,\n        )\n\n        hosts: List[ResolveResult] = []\n        for family, _, proto, _, address in infos:\n            if family == socket.AF_INET6:\n                if len(address) < 3:\n                    # IPv6 is not supported by Python build,\n                    # or IPv6 is not enabled in the host\n                    continue\n                if address[3] and _SUPPORTS_SCOPE_ID:\n                    # This is essential for link-local IPv6 addresses.\n                    # LL IPv6 is a VERY rare case. Strictly speaking, we should use\n                    # getnameinfo() unconditionally, but performance makes sense.\n                    resolved_host, _port = await self._loop.getnameinfo(\n                        address, _NAME_SOCKET_FLAGS\n                    )\n                    port = int(_port)\n                else:\n                    resolved_host, port = address[:2]\n            else:  # IPv4\n                assert family == socket.AF_INET\n                resolved_host, port = address  # type: ignore[misc]\n            hosts.append(\n                ResolveResult(\n                    hostname=host,\n                    host=resolved_host,\n                    port=port,\n                    family=family,\n                    proto=proto,\n                    flags=_NUMERIC_SOCKET_FLAGS,\n                )\n            )\n\n        return hosts\n\n    async def close(self) -> None:\n        pass\n\n\nclass AsyncResolver(AbstractResolver):\n    \"\"\"Use the `aiodns` package to make asynchronous DNS lookups\"\"\"\n\n    def __init__(\n        self,\n        loop: Optional[asyncio.AbstractEventLoop] = None,\n        *args: Any,\n        **kwargs: Any\n    ) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\n\n        if not hasattr(self._resolver, \"gethostbyname\"):\n            # aiodns 1.1 is not available, fallback to DNSResolver.query\n            self.resolve = self._resolve_with_query  # type: ignore\n\n    async def resolve(\n        self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET\n    ) -> List[ResolveResult]:\n        try:\n            resp = await self._resolver.getaddrinfo(\n                host,\n                port=port,\n                type=socket.SOCK_STREAM,\n                family=family,\n                flags=socket.AI_ADDRCONFIG,\n            )\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(None, msg) from exc\n        hosts: List[ResolveResult] = []\n        for node in resp.nodes:\n            address: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]] = node.addr\n            family = node.family\n            if family == socket.AF_INET6:\n                if len(address) > 3 and address[3] and _SUPPORTS_SCOPE_ID:\n                    # This is essential for link-local IPv6 addresses.\n                    # LL IPv6 is a VERY rare case. Strictly speaking, we should use\n                    # getnameinfo() unconditionally, but performance makes sense.\n                    result = await self._resolver.getnameinfo(\n                        (address[0].decode(\"ascii\"), *address[1:]),\n                        _NAME_SOCKET_FLAGS,\n                    )\n                    resolved_host = result.node\n                else:\n                    resolved_host = address[0].decode(\"ascii\")\n                    port = address[1]\n            else:  # IPv4\n                assert family == socket.AF_INET\n                resolved_host = address[0].decode(\"ascii\")\n                port = address[1]\n            hosts.append(\n                ResolveResult(\n                    hostname=host,\n                    host=resolved_host,\n                    port=port,\n                    family=family,\n                    proto=0,\n                    flags=_NUMERIC_SOCKET_FLAGS,\n                )\n            )\n\n        if not hosts:\n            raise OSError(None, \"DNS lookup failed\")\n\n        return hosts\n\n    async def _resolve_with_query(\n        self, host: str, port: int = 0, family: int = socket.AF_INET\n    ) -> List[Dict[str, Any]]:\n        if family == socket.AF_INET6:\n            qtype = \"AAAA\"\n        else:\n            qtype = \"A\"\n\n        try:\n            resp = await self._resolver.query(host, qtype)\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(msg) from exc\n\n        hosts = []\n        for rr in resp:\n            hosts.append(\n                {\n                    \"hostname\": host,\n                    \"host\": rr.host,\n                    \"port\": port,\n                    \"family\": family,\n                    \"proto\": 0,\n                    \"flags\": socket.AI_NUMERICHOST,\n                }\n            )\n\n        if not hosts:\n            raise OSError(\"DNS lookup failed\")\n\n        return hosts\n\n    async def close(self) -> None:\n        self._resolver.cancel()\n\n\n_DefaultType = Type[Union[AsyncResolver, ThreadedResolver]]\nDefaultResolver: _DefaultType = AsyncResolver if aiodns_default else ThreadedResolver\n",
            "new_file_content": "import asyncio\nimport socket\nimport sys\nfrom typing import Any, Dict, List, Optional, Tuple, Type, Union\n\nfrom .abc import AbstractResolver, ResolveResult\n\n__all__ = (\"ThreadedResolver\", \"AsyncResolver\", \"DefaultResolver\")\n\n\ntry:\n    import aiodns\n\n    aiodns_default = hasattr(aiodns.DNSResolver, \"getaddrinfo\")\nexcept ImportError:  # pragma: no cover\n    aiodns = None  # type: ignore[assignment]\n    aiodns_default = False\n\n\n_NUMERIC_SOCKET_FLAGS = socket.AI_NUMERICHOST | socket.AI_NUMERICSERV\n_NAME_SOCKET_FLAGS = socket.NI_NUMERICHOST | socket.NI_NUMERICSERV\n_SUPPORTS_SCOPE_ID = sys.version_info >= (3, 9, 0)\n\n\nclass ThreadedResolver(AbstractResolver):\n    \"\"\"Threaded resolver.\n\n    Uses an Executor for synchronous getaddrinfo() calls.\n    concurrent.futures.ThreadPoolExecutor is used by default.\n    \"\"\"\n\n    def __init__(self, loop: Optional[asyncio.AbstractEventLoop] = None) -> None:\n        self._loop = loop or asyncio.get_running_loop()\n\n    async def resolve(\n        self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET\n    ) -> List[ResolveResult]:\n        infos = await self._loop.getaddrinfo(\n            host,\n            port,\n            type=socket.SOCK_STREAM,\n            family=family,\n            flags=socket.AI_ADDRCONFIG,\n        )\n\n        hosts: List[ResolveResult] = []\n        for family, _, proto, _, address in infos:\n            if family == socket.AF_INET6:\n                if len(address) < 3:\n                    # IPv6 is not supported by Python build,\n                    # or IPv6 is not enabled in the host\n                    continue\n                if address[3] and _SUPPORTS_SCOPE_ID:\n                    # This is essential for link-local IPv6 addresses.\n                    # LL IPv6 is a VERY rare case. Strictly speaking, we should use\n                    # getnameinfo() unconditionally, but performance makes sense.\n                    resolved_host, _port = await self._loop.getnameinfo(\n                        address, _NAME_SOCKET_FLAGS\n                    )\n                    port = int(_port)\n                else:\n                    resolved_host, port = address[:2]\n            else:  # IPv4\n                assert family == socket.AF_INET\n                resolved_host, port = address  # type: ignore[misc]\n            hosts.append(\n                ResolveResult(\n                    hostname=host,\n                    host=resolved_host,\n                    port=port,\n                    family=family,\n                    proto=proto,\n                    flags=_NUMERIC_SOCKET_FLAGS,\n                )\n            )\n\n        return hosts\n\n    async def close(self) -> None:\n        pass\n\n\nclass AsyncResolver(AbstractResolver):\n    \"\"\"Use the `aiodns` package to make asynchronous DNS lookups\"\"\"\n\n    def __init__(\n        self,\n        loop: Optional[asyncio.AbstractEventLoop] = None,\n        *args: Any,\n        **kwargs: Any\n    ) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\n\n        if not hasattr(self._resolver, \"gethostbyname\"):\n            # aiodns 1.1 is not available, fallback to DNSResolver.query\n            self.resolve = self._resolve_with_query  # type: ignore\n\n    async def resolve(\n        self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET\n    ) -> List[ResolveResult]:\n        try:\n            resp = await self._resolver.getaddrinfo(\n                host,\n                port=port,\n                type=socket.SOCK_STREAM,\n                family=family,\n                flags=socket.AI_ADDRCONFIG,\n            )\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(None, msg) from exc\n        hosts: List[ResolveResult] = []\n        for node in resp.nodes:\n            address: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]] = node.addr\n            family = node.family\n            if family == socket.AF_INET6:\n                if len(address) > 3 and address[3] and _SUPPORTS_SCOPE_ID:\n                    # This is essential for link-local IPv6 addresses.\n                    # LL IPv6 is a VERY rare case. Strictly speaking, we should use\n                    # getnameinfo() unconditionally, but performance makes sense.\n                    result = await self._resolver.getnameinfo(\n                        (address[0].decode(\"ascii\"), *address[1:]),\n                        _NAME_SOCKET_FLAGS,\n                    )\n                    resolved_host = result.node\n                else:\n                    resolved_host = address[0].decode(\"ascii\")\n                    port = address[1]\n            else:  # IPv4\n                assert family == socket.AF_INET\n                resolved_host = address[0].decode(\"ascii\")\n                port = address[1]\n            hosts.append(\n                ResolveResult(\n                    hostname=host,\n                    host=resolved_host,\n                    port=port,\n                    family=family,\n                    proto=0,\n                    flags=_NUMERIC_SOCKET_FLAGS,\n                )\n            )\n\n        if not hosts:\n            raise OSError(None, \"DNS lookup failed\")\n\n        return hosts\n\n    async def _resolve_with_query(\n        self, host: str, port: int = 0, family: int = socket.AF_INET\n    ) -> List[Dict[str, Any]]:\n        if family == socket.AF_INET6:\n            qtype = \"AAAA\"\n        else:\n            qtype = \"A\"\n\n        try:\n            resp = await self._resolver.query(host, qtype)\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(None, msg) from exc\n\n        hosts = []\n        for rr in resp:\n            hosts.append(\n                {\n                    \"hostname\": host,\n                    \"host\": rr.host,\n                    \"port\": port,\n                    \"family\": family,\n                    \"proto\": 0,\n                    \"flags\": socket.AI_NUMERICHOST,\n                }\n            )\n\n        if not hosts:\n            raise OSError(None, \"DNS lookup failed\")\n\n        return hosts\n\n    async def close(self) -> None:\n        self._resolver.cancel()\n\n\n_DefaultType = Type[Union[AsyncResolver, ThreadedResolver]]\nDefaultResolver: _DefaultType = AsyncResolver if aiodns_default else ThreadedResolver\n",
            "header": {
                "file": {
                    "path": "aiohttp/resolver.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "385ae21a",
                "new_commit_hash": "c01a46fb",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/aiohttp/resolver.py"
            },
            "plus_file": {
                "path": "b/aiohttp/resolver.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 161,
                            "length": 7
                        },
                        "new_range": {
                            "start": 161,
                            "length": 7
                        },
                        "section": "class AsyncResolver(AbstractResolver):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "            resp = await self._resolver.query(host, qtype)",
                                "type": "context"
                            },
                            {
                                "content": "        except aiodns.error.DNSError as exc:",
                                "type": "context"
                            },
                            {
                                "content": "            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"",
                                "type": "context"
                            },
                            {
                                "content": "            raise OSError(msg) from exc",
                                "type": "deleted"
                            },
                            {
                                "content": "            raise OSError(None, msg) from exc",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        hosts = []",
                                "type": "context"
                            },
                            {
                                "content": "        for rr in resp:",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "aiohttp/resolver.py",
                            "type": "method",
                            "name": "AsyncResolver._resolve_with_query",
                            "content": "class AsyncResolver(AbstractResolver):\n    \"\"\"Use the `aiodns` package to make asynchronous DNS lookups\"\"\"\n\n    def __init__(\n        self,\n        loop: Optional[asyncio.AbstractEventLoop] = None,\n        *args: Any,\n        **kwargs: Any\n    ) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\n\n        if not hasattr(self._resolver, \"gethostbyname\"):\n            # aiodns 1.1 is not available, fallback to DNSResolver.query\n            self.resolve = self._resolve_with_query  # type: ignore\n\n    async def resolve(\n        self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET\n    ) -> List[ResolveResult]:\n        try:\n            resp = await self._resolver.getaddrinfo(\n                host,\n                port=port,\n                type=socket.SOCK_STREAM,\n                family=family,\n                flags=socket.AI_ADDRCONFIG,\n            )\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(None, msg) from exc\n        hosts: List[ResolveResult] = []\n        for node in resp.nodes:\n            address: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]] = node.addr\n            family = node.family\n            if family == socket.AF_INET6:\n                if len(address) > 3 and address[3] and _SUPPORTS_SCOPE_ID:\n                    # This is essential for link-local IPv6 addresses.\n                    # LL IPv6 is a VERY rare case. Strictly speaking, we should use\n                    # getnameinfo() unconditionally, but performance makes sense.\n                    result = await self._resolver.getnameinfo(\n                        (address[0].decode(\"ascii\"), *address[1:]),\n                        _NAME_SOCKET_FLAGS,\n                    )\n                    resolved_host = result.node\n                else:\n                    resolved_host = address[0].decode(\"ascii\")\n                    port = address[1]\n            else:  # IPv4\n                assert family == socket.AF_INET\n                resolved_host = address[0].decode(\"ascii\")\n                port = address[1]\n            hosts.append(\n                ResolveResult(\n                    hostname=host,\n                    host=resolved_host,\n                    port=port,\n                    family=family,\n                    proto=0,\n                    flags=_NUMERIC_SOCKET_FLAGS,\n                )\n            )\n\n        if not hosts:\n            raise OSError(None, \"DNS lookup failed\")\n\n        return hosts\n\n    async def _resolve_with_query(\n        self, host: str, port: int = 0, family: int = socket.AF_INET\n    ) -> List[Dict[str, Any]]:\n        if family == socket.AF_INET6:\n            qtype = \"AAAA\"\n        else:\n            qtype = \"A\"\n\n        try:\n            resp = await self._resolver.query(host, qtype)\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(msg) from exc\n\n        hosts = []\n        for rr in resp:\n            hosts.append(\n                {\n                    \"hostname\": host,\n                    \"host\": rr.host,\n                    \"port\": port,\n                    \"family\": family,\n                    \"proto\": 0,\n                    \"flags\": socket.AI_NUMERICHOST,\n                }\n            )\n\n        if not hosts:\n            raise OSError(\"DNS lookup failed\")\n\n        return hosts\n\n    async def close(self) -> None:\n        self._resolver.cancel()",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 152,
                            "end_lineno": 182,
                            "parent": {
                                "file_name": "aiohttp/resolver.py",
                                "type": "class",
                                "name": "AsyncResolver",
                                "content": "class AsyncResolver(AbstractResolver):\n    \"\"\"Use the `aiodns` package to make asynchronous DNS lookups\"\"\"\n\n    def __init__(\n        self,\n        loop: Optional[asyncio.AbstractEventLoop] = None,\n        *args: Any,\n        **kwargs: Any\n    ) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\n\n        if not hasattr(self._resolver, \"gethostbyname\"):\n            # aiodns 1.1 is not available, fallback to DNSResolver.query\n            self.resolve = self._resolve_with_query  # type: ignore\n\n    async def resolve(\n        self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET\n    ) -> List[ResolveResult]:\n        try:\n            resp = await self._resolver.getaddrinfo(\n                host,\n                port=port,\n                type=socket.SOCK_STREAM,\n                family=family,\n                flags=socket.AI_ADDRCONFIG,\n            )\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(None, msg) from exc\n        hosts: List[ResolveResult] = []\n        for node in resp.nodes:\n            address: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]] = node.addr\n            family = node.family\n            if family == socket.AF_INET6:\n                if len(address) > 3 and address[3] and _SUPPORTS_SCOPE_ID:\n                    # This is essential for link-local IPv6 addresses.\n                    # LL IPv6 is a VERY rare case. Strictly speaking, we should use\n                    # getnameinfo() unconditionally, but performance makes sense.\n                    result = await self._resolver.getnameinfo(\n                        (address[0].decode(\"ascii\"), *address[1:]),\n                        _NAME_SOCKET_FLAGS,\n                    )\n                    resolved_host = result.node\n                else:\n                    resolved_host = address[0].decode(\"ascii\")\n                    port = address[1]\n            else:  # IPv4\n                assert family == socket.AF_INET\n                resolved_host = address[0].decode(\"ascii\")\n                port = address[1]\n            hosts.append(\n                ResolveResult(\n                    hostname=host,\n                    host=resolved_host,\n                    port=port,\n                    family=family,\n                    proto=0,\n                    flags=_NUMERIC_SOCKET_FLAGS,\n                )\n            )\n\n        if not hosts:\n            raise OSError(None, \"DNS lookup failed\")\n\n        return hosts\n\n    async def _resolve_with_query(\n        self, host: str, port: int = 0, family: int = socket.AF_INET\n    ) -> List[Dict[str, Any]]:\n        if family == socket.AF_INET6:\n            qtype = \"AAAA\"\n        else:\n            qtype = \"A\"\n\n        try:\n            resp = await self._resolver.query(host, qtype)\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(msg) from exc\n\n        hosts = []\n        for rr in resp:\n            hosts.append(\n                {\n                    \"hostname\": host,\n                    \"host\": rr.host,\n                    \"port\": port,\n                    \"family\": family,\n                    \"proto\": 0,\n                    \"flags\": socket.AI_NUMERICHOST,\n                }\n            )\n\n        if not hosts:\n            raise OSError(\"DNS lookup failed\")\n\n        return hosts\n\n    async def close(self) -> None:\n        self._resolver.cancel()",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 83,
                                "end_lineno": 185,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "aiohttp/resolver.py",
                            "type": "class",
                            "name": "AsyncResolver",
                            "content": "class AsyncResolver(AbstractResolver):\n    \"\"\"Use the `aiodns` package to make asynchronous DNS lookups\"\"\"\n\n    def __init__(\n        self,\n        loop: Optional[asyncio.AbstractEventLoop] = None,\n        *args: Any,\n        **kwargs: Any\n    ) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\n\n        if not hasattr(self._resolver, \"gethostbyname\"):\n            # aiodns 1.1 is not available, fallback to DNSResolver.query\n            self.resolve = self._resolve_with_query  # type: ignore\n\n    async def resolve(\n        self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET\n    ) -> List[ResolveResult]:\n        try:\n            resp = await self._resolver.getaddrinfo(\n                host,\n                port=port,\n                type=socket.SOCK_STREAM,\n                family=family,\n                flags=socket.AI_ADDRCONFIG,\n            )\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(None, msg) from exc\n        hosts: List[ResolveResult] = []\n        for node in resp.nodes:\n            address: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]] = node.addr\n            family = node.family\n            if family == socket.AF_INET6:\n                if len(address) > 3 and address[3] and _SUPPORTS_SCOPE_ID:\n                    # This is essential for link-local IPv6 addresses.\n                    # LL IPv6 is a VERY rare case. Strictly speaking, we should use\n                    # getnameinfo() unconditionally, but performance makes sense.\n                    result = await self._resolver.getnameinfo(\n                        (address[0].decode(\"ascii\"), *address[1:]),\n                        _NAME_SOCKET_FLAGS,\n                    )\n                    resolved_host = result.node\n                else:\n                    resolved_host = address[0].decode(\"ascii\")\n                    port = address[1]\n            else:  # IPv4\n                assert family == socket.AF_INET\n                resolved_host = address[0].decode(\"ascii\")\n                port = address[1]\n            hosts.append(\n                ResolveResult(\n                    hostname=host,\n                    host=resolved_host,\n                    port=port,\n                    family=family,\n                    proto=0,\n                    flags=_NUMERIC_SOCKET_FLAGS,\n                )\n            )\n\n        if not hosts:\n            raise OSError(None, \"DNS lookup failed\")\n\n        return hosts\n\n    async def _resolve_with_query(\n        self, host: str, port: int = 0, family: int = socket.AF_INET\n    ) -> List[Dict[str, Any]]:\n        if family == socket.AF_INET6:\n            qtype = \"AAAA\"\n        else:\n            qtype = \"A\"\n\n        try:\n            resp = await self._resolver.query(host, qtype)\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(msg) from exc\n\n        hosts = []\n        for rr in resp:\n            hosts.append(\n                {\n                    \"hostname\": host,\n                    \"host\": rr.host,\n                    \"port\": port,\n                    \"family\": family,\n                    \"proto\": 0,\n                    \"flags\": socket.AI_NUMERICHOST,\n                }\n            )\n\n        if not hosts:\n            raise OSError(\"DNS lookup failed\")\n\n        return hosts\n\n    async def close(self) -> None:\n        self._resolver.cancel()",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 83,
                            "end_lineno": 185,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 177,
                            "length": 7
                        },
                        "new_range": {
                            "start": 177,
                            "length": 7
                        },
                        "section": "class AsyncResolver(AbstractResolver):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "            )",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        if not hosts:",
                                "type": "context"
                            },
                            {
                                "content": "            raise OSError(\"DNS lookup failed\")",
                                "type": "deleted"
                            },
                            {
                                "content": "            raise OSError(None, \"DNS lookup failed\")",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        return hosts",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "aiohttp/resolver.py",
                            "type": "method",
                            "name": "AsyncResolver._resolve_with_query",
                            "content": "class AsyncResolver(AbstractResolver):\n    \"\"\"Use the `aiodns` package to make asynchronous DNS lookups\"\"\"\n\n    def __init__(\n        self,\n        loop: Optional[asyncio.AbstractEventLoop] = None,\n        *args: Any,\n        **kwargs: Any\n    ) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\n\n        if not hasattr(self._resolver, \"gethostbyname\"):\n            # aiodns 1.1 is not available, fallback to DNSResolver.query\n            self.resolve = self._resolve_with_query  # type: ignore\n\n    async def resolve(\n        self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET\n    ) -> List[ResolveResult]:\n        try:\n            resp = await self._resolver.getaddrinfo(\n                host,\n                port=port,\n                type=socket.SOCK_STREAM,\n                family=family,\n                flags=socket.AI_ADDRCONFIG,\n            )\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(None, msg) from exc\n        hosts: List[ResolveResult] = []\n        for node in resp.nodes:\n            address: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]] = node.addr\n            family = node.family\n            if family == socket.AF_INET6:\n                if len(address) > 3 and address[3] and _SUPPORTS_SCOPE_ID:\n                    # This is essential for link-local IPv6 addresses.\n                    # LL IPv6 is a VERY rare case. Strictly speaking, we should use\n                    # getnameinfo() unconditionally, but performance makes sense.\n                    result = await self._resolver.getnameinfo(\n                        (address[0].decode(\"ascii\"), *address[1:]),\n                        _NAME_SOCKET_FLAGS,\n                    )\n                    resolved_host = result.node\n                else:\n                    resolved_host = address[0].decode(\"ascii\")\n                    port = address[1]\n            else:  # IPv4\n                assert family == socket.AF_INET\n                resolved_host = address[0].decode(\"ascii\")\n                port = address[1]\n            hosts.append(\n                ResolveResult(\n                    hostname=host,\n                    host=resolved_host,\n                    port=port,\n                    family=family,\n                    proto=0,\n                    flags=_NUMERIC_SOCKET_FLAGS,\n                )\n            )\n\n        if not hosts:\n            raise OSError(None, \"DNS lookup failed\")\n\n        return hosts\n\n    async def _resolve_with_query(\n        self, host: str, port: int = 0, family: int = socket.AF_INET\n    ) -> List[Dict[str, Any]]:\n        if family == socket.AF_INET6:\n            qtype = \"AAAA\"\n        else:\n            qtype = \"A\"\n\n        try:\n            resp = await self._resolver.query(host, qtype)\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(msg) from exc\n\n        hosts = []\n        for rr in resp:\n            hosts.append(\n                {\n                    \"hostname\": host,\n                    \"host\": rr.host,\n                    \"port\": port,\n                    \"family\": family,\n                    \"proto\": 0,\n                    \"flags\": socket.AI_NUMERICHOST,\n                }\n            )\n\n        if not hosts:\n            raise OSError(\"DNS lookup failed\")\n\n        return hosts\n\n    async def close(self) -> None:\n        self._resolver.cancel()",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 152,
                            "end_lineno": 182,
                            "parent": {
                                "file_name": "aiohttp/resolver.py",
                                "type": "class",
                                "name": "AsyncResolver",
                                "content": "class AsyncResolver(AbstractResolver):\n    \"\"\"Use the `aiodns` package to make asynchronous DNS lookups\"\"\"\n\n    def __init__(\n        self,\n        loop: Optional[asyncio.AbstractEventLoop] = None,\n        *args: Any,\n        **kwargs: Any\n    ) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\n\n        if not hasattr(self._resolver, \"gethostbyname\"):\n            # aiodns 1.1 is not available, fallback to DNSResolver.query\n            self.resolve = self._resolve_with_query  # type: ignore\n\n    async def resolve(\n        self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET\n    ) -> List[ResolveResult]:\n        try:\n            resp = await self._resolver.getaddrinfo(\n                host,\n                port=port,\n                type=socket.SOCK_STREAM,\n                family=family,\n                flags=socket.AI_ADDRCONFIG,\n            )\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(None, msg) from exc\n        hosts: List[ResolveResult] = []\n        for node in resp.nodes:\n            address: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]] = node.addr\n            family = node.family\n            if family == socket.AF_INET6:\n                if len(address) > 3 and address[3] and _SUPPORTS_SCOPE_ID:\n                    # This is essential for link-local IPv6 addresses.\n                    # LL IPv6 is a VERY rare case. Strictly speaking, we should use\n                    # getnameinfo() unconditionally, but performance makes sense.\n                    result = await self._resolver.getnameinfo(\n                        (address[0].decode(\"ascii\"), *address[1:]),\n                        _NAME_SOCKET_FLAGS,\n                    )\n                    resolved_host = result.node\n                else:\n                    resolved_host = address[0].decode(\"ascii\")\n                    port = address[1]\n            else:  # IPv4\n                assert family == socket.AF_INET\n                resolved_host = address[0].decode(\"ascii\")\n                port = address[1]\n            hosts.append(\n                ResolveResult(\n                    hostname=host,\n                    host=resolved_host,\n                    port=port,\n                    family=family,\n                    proto=0,\n                    flags=_NUMERIC_SOCKET_FLAGS,\n                )\n            )\n\n        if not hosts:\n            raise OSError(None, \"DNS lookup failed\")\n\n        return hosts\n\n    async def _resolve_with_query(\n        self, host: str, port: int = 0, family: int = socket.AF_INET\n    ) -> List[Dict[str, Any]]:\n        if family == socket.AF_INET6:\n            qtype = \"AAAA\"\n        else:\n            qtype = \"A\"\n\n        try:\n            resp = await self._resolver.query(host, qtype)\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(msg) from exc\n\n        hosts = []\n        for rr in resp:\n            hosts.append(\n                {\n                    \"hostname\": host,\n                    \"host\": rr.host,\n                    \"port\": port,\n                    \"family\": family,\n                    \"proto\": 0,\n                    \"flags\": socket.AI_NUMERICHOST,\n                }\n            )\n\n        if not hosts:\n            raise OSError(\"DNS lookup failed\")\n\n        return hosts\n\n    async def close(self) -> None:\n        self._resolver.cancel()",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 83,
                                "end_lineno": 185,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "aiohttp/resolver.py",
                            "type": "class",
                            "name": "AsyncResolver",
                            "content": "class AsyncResolver(AbstractResolver):\n    \"\"\"Use the `aiodns` package to make asynchronous DNS lookups\"\"\"\n\n    def __init__(\n        self,\n        loop: Optional[asyncio.AbstractEventLoop] = None,\n        *args: Any,\n        **kwargs: Any\n    ) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\n\n        if not hasattr(self._resolver, \"gethostbyname\"):\n            # aiodns 1.1 is not available, fallback to DNSResolver.query\n            self.resolve = self._resolve_with_query  # type: ignore\n\n    async def resolve(\n        self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET\n    ) -> List[ResolveResult]:\n        try:\n            resp = await self._resolver.getaddrinfo(\n                host,\n                port=port,\n                type=socket.SOCK_STREAM,\n                family=family,\n                flags=socket.AI_ADDRCONFIG,\n            )\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(None, msg) from exc\n        hosts: List[ResolveResult] = []\n        for node in resp.nodes:\n            address: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]] = node.addr\n            family = node.family\n            if family == socket.AF_INET6:\n                if len(address) > 3 and address[3] and _SUPPORTS_SCOPE_ID:\n                    # This is essential for link-local IPv6 addresses.\n                    # LL IPv6 is a VERY rare case. Strictly speaking, we should use\n                    # getnameinfo() unconditionally, but performance makes sense.\n                    result = await self._resolver.getnameinfo(\n                        (address[0].decode(\"ascii\"), *address[1:]),\n                        _NAME_SOCKET_FLAGS,\n                    )\n                    resolved_host = result.node\n                else:\n                    resolved_host = address[0].decode(\"ascii\")\n                    port = address[1]\n            else:  # IPv4\n                assert family == socket.AF_INET\n                resolved_host = address[0].decode(\"ascii\")\n                port = address[1]\n            hosts.append(\n                ResolveResult(\n                    hostname=host,\n                    host=resolved_host,\n                    port=port,\n                    family=family,\n                    proto=0,\n                    flags=_NUMERIC_SOCKET_FLAGS,\n                )\n            )\n\n        if not hosts:\n            raise OSError(None, \"DNS lookup failed\")\n\n        return hosts\n\n    async def _resolve_with_query(\n        self, host: str, port: int = 0, family: int = socket.AF_INET\n    ) -> List[Dict[str, Any]]:\n        if family == socket.AF_INET6:\n            qtype = \"AAAA\"\n        else:\n            qtype = \"A\"\n\n        try:\n            resp = await self._resolver.query(host, qtype)\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(msg) from exc\n\n        hosts = []\n        for rr in resp:\n            hosts.append(\n                {\n                    \"hostname\": host,\n                    \"host\": rr.host,\n                    \"port\": port,\n                    \"family\": family,\n                    \"proto\": 0,\n                    \"flags\": socket.AI_NUMERICHOST,\n                }\n            )\n\n        if not hosts:\n            raise OSError(\"DNS lookup failed\")\n\n        return hosts\n\n    async def close(self) -> None:\n        self._resolver.cancel()",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 83,
                            "end_lineno": 185,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "import asyncio\nimport ipaddress\nimport socket\nfrom ipaddress import ip_address\nfrom typing import Any, Awaitable, Callable, Collection, List, NamedTuple, Tuple, Union\nfrom unittest.mock import Mock, create_autospec, patch\n\nimport pytest\n\nfrom aiohttp.resolver import (\n    _NAME_SOCKET_FLAGS,\n    _SUPPORTS_SCOPE_ID,\n    AsyncResolver,\n    DefaultResolver,\n    ThreadedResolver,\n)\n\ntry:\n    import aiodns\n\n    getaddrinfo: Any = hasattr(aiodns.DNSResolver, \"getaddrinfo\")\nexcept ImportError:\n    aiodns = None  # type: ignore[assignment]\n    getaddrinfo = False\n\n\nclass FakeAIODNSAddrInfoNode(NamedTuple):\n\n    family: int\n    addr: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]]\n\n\nclass FakeAIODNSAddrInfoIPv4Result:\n    def __init__(self, hosts: Collection[str]) -> None:\n        self.nodes = [\n            FakeAIODNSAddrInfoNode(socket.AF_INET, (h.encode(), 0)) for h in hosts\n        ]\n\n\nclass FakeAIODNSAddrInfoIPv6Result:\n    def __init__(self, hosts: Collection[str]) -> None:\n        self.nodes = [\n            FakeAIODNSAddrInfoNode(\n                socket.AF_INET6,\n                (h.encode(), 0, 0, 3 if ip_address(h).is_link_local else 0),\n            )\n            for h in hosts\n        ]\n\n\nclass FakeAIODNSNameInfoIPv6Result:\n    def __init__(self, host: str) -> None:\n        self.node = host\n        self.service = None\n\n\nclass FakeQueryResult:\n    def __init__(self, host):\n        self.host = host\n\n\nasync def fake_aiodns_getaddrinfo_ipv4_result(\n    hosts: Collection[str],\n) -> FakeAIODNSAddrInfoIPv4Result:\n    return FakeAIODNSAddrInfoIPv4Result(hosts=hosts)\n\n\nasync def fake_aiodns_getaddrinfo_ipv6_result(\n    hosts: Collection[str],\n) -> FakeAIODNSAddrInfoIPv6Result:\n    return FakeAIODNSAddrInfoIPv6Result(hosts=hosts)\n\n\nasync def fake_aiodns_getnameinfo_ipv6_result(\n    host: str,\n) -> FakeAIODNSNameInfoIPv6Result:\n    return FakeAIODNSNameInfoIPv6Result(host)\n\n\nasync def fake_query_result(result):\n    return [FakeQueryResult(host=h) for h in result]\n\n\ndef fake_addrinfo(hosts: Collection[str]) -> Callable[..., Awaitable[Any]]:\n    async def fake(*args: Any, **kwargs: Any) -> List[Any]:\n        if not hosts:\n            raise socket.gaierror\n\n        return [(socket.AF_INET, None, socket.SOCK_STREAM, None, [h, 0]) for h in hosts]\n\n    return fake\n\n\ndef fake_ipv6_addrinfo(hosts: Collection[str]) -> Callable[..., Awaitable[Any]]:\n    async def fake(*args: Any, **kwargs: Any) -> List[Any]:\n        if not hosts:\n            raise socket.gaierror\n\n        return [\n            (\n                socket.AF_INET6,\n                None,\n                socket.SOCK_STREAM,\n                None,\n                (h, 0, 0, 3 if ip_address(h).is_link_local else 0),\n            )\n            for h in hosts\n        ]\n\n    return fake\n\n\ndef fake_ipv6_nameinfo(host: str) -> Callable[..., Awaitable[Any]]:\n    async def fake(*args: Any, **kwargs: Any) -> Tuple[str, int]:\n        return host, 0\n\n    return fake\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_positive_ipv4_lookup(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv4_result(\n            [\"127.0.0.1\"]\n        )\n        resolver = AsyncResolver()\n        real = await resolver.resolve(\"www.python.org\")\n        ipaddress.ip_address(real[0][\"host\"])\n        mock().getaddrinfo.assert_called_with(\n            \"www.python.org\",\n            family=socket.AF_INET,\n            flags=socket.AI_ADDRCONFIG,\n            port=0,\n            type=socket.SOCK_STREAM,\n        )\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\n@pytest.mark.skipif(\n    not _SUPPORTS_SCOPE_ID, reason=\"python version does not support scope id\"\n)\nasync def test_async_resolver_positive_link_local_ipv6_lookup(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv6_result(\n            [\"fe80::1\"]\n        )\n        mock().getnameinfo.return_value = fake_aiodns_getnameinfo_ipv6_result(\n            \"fe80::1%eth0\"\n        )\n        resolver = AsyncResolver()\n        real = await resolver.resolve(\"www.python.org\")\n        ipaddress.ip_address(real[0][\"host\"])\n        mock().getaddrinfo.assert_called_with(\n            \"www.python.org\",\n            family=socket.AF_INET,\n            flags=socket.AI_ADDRCONFIG,\n            port=0,\n            type=socket.SOCK_STREAM,\n        )\n        mock().getnameinfo.assert_called_with((\"fe80::1\", 0, 0, 3), _NAME_SOCKET_FLAGS)\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_multiple_replies(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        ips = [\"127.0.0.1\", \"127.0.0.2\", \"127.0.0.3\", \"127.0.0.4\"]\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv4_result(ips)\n        resolver = AsyncResolver()\n        real = await resolver.resolve(\"www.google.com\")\n        ips = [ipaddress.ip_address(x[\"host\"]) for x in real]\n        assert len(ips) > 3, \"Expecting multiple addresses\"\n\n\n@pytest.mark.skipif(aiodns is None, reason=\"aiodns required\")\nasync def test_async_resolver_query_multiple_replies(loop) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        del mock().gethostbyname\n        ips = [\"127.0.0.1\", \"127.0.0.2\", \"127.0.0.3\", \"127.0.0.4\"]\n        mock().query.return_value = fake_query_result(ips)\n        resolver = AsyncResolver(loop=loop)\n        real = await resolver.resolve(\"www.google.com\")\n        ips = [ipaddress.ip_address(x[\"host\"]) for x in real]\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_negative_lookup(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        mock().getaddrinfo.side_effect = aiodns.error.DNSError()\n        resolver = AsyncResolver()\n        with pytest.raises(OSError):\n            await resolver.resolve(\"doesnotexist.bla\")\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_no_hosts_in_getaddrinfo(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv4_result([])\n        resolver = AsyncResolver()\n        with pytest.raises(OSError):\n            await resolver.resolve(\"doesnotexist.bla\")\n\n\nasync def test_threaded_resolver_positive_lookup() -> None:\n    loop = Mock()\n    loop.getaddrinfo = fake_addrinfo([\"127.0.0.1\"])\n    resolver = ThreadedResolver(loop=loop)\n    real = await resolver.resolve(\"www.python.org\")\n    assert real[0][\"hostname\"] == \"www.python.org\"\n    ipaddress.ip_address(real[0][\"host\"])\n\n\n@pytest.mark.skipif(\n    not _SUPPORTS_SCOPE_ID, reason=\"python version does not support scope id\"\n)\nasync def test_threaded_resolver_positive_ipv6_link_local_lookup() -> None:\n    loop = Mock()\n    loop.getaddrinfo = fake_ipv6_addrinfo([\"fe80::1\"])\n    loop.getnameinfo = fake_ipv6_nameinfo(\"fe80::1%eth0\")\n\n    # Mock the fake function that was returned by helper functions\n    loop.getaddrinfo = create_autospec(loop.getaddrinfo)\n    loop.getnameinfo = create_autospec(loop.getnameinfo)\n\n    # Set the correct return values for mock functions\n    loop.getaddrinfo.return_value = await fake_ipv6_addrinfo([\"fe80::1\"])()\n    loop.getnameinfo.return_value = await fake_ipv6_nameinfo(\"fe80::1%eth0\")()\n\n    resolver = ThreadedResolver()\n    resolver._loop = loop\n    real = await resolver.resolve(\"www.python.org\")\n    assert real[0][\"hostname\"] == \"www.python.org\"\n    ipaddress.ip_address(real[0][\"host\"])\n\n    loop.getaddrinfo.assert_called_with(\n        \"www.python.org\",\n        0,\n        type=socket.SOCK_STREAM,\n        family=socket.AF_INET,\n        flags=socket.AI_ADDRCONFIG,\n    )\n\n    loop.getnameinfo.assert_called_with((\"fe80::1\", 0, 0, 3), _NAME_SOCKET_FLAGS)\n\n\nasync def test_threaded_resolver_multiple_replies() -> None:\n    loop = Mock()\n    ips = [\"127.0.0.1\", \"127.0.0.2\", \"127.0.0.3\", \"127.0.0.4\"]\n    loop.getaddrinfo = fake_addrinfo(ips)\n    resolver = ThreadedResolver(loop=loop)\n    real = await resolver.resolve(\"www.google.com\")\n    ips = [ipaddress.ip_address(x[\"host\"]) for x in real]\n    assert len(ips) > 3, \"Expecting multiple addresses\"\n\n\nasync def test_threaded_negative_lookup() -> None:\n    loop = Mock()\n    ips = []\n    loop.getaddrinfo = fake_addrinfo(ips)\n    resolver = ThreadedResolver(loop=loop)\n    with pytest.raises(socket.gaierror):\n        await resolver.resolve(\"doesnotexist.bla\")\n\n\nasync def test_threaded_negative_ipv6_lookup() -> None:\n    loop = Mock()\n    ips: List[Any] = []\n    loop.getaddrinfo = fake_ipv6_addrinfo(ips)\n    resolver = ThreadedResolver()\n    resolver._loop = loop\n    with pytest.raises(socket.gaierror):\n        await resolver.resolve(\"doesnotexist.bla\")\n\n\nasync def test_threaded_negative_lookup_with_unknown_result() -> None:\n    loop = Mock()\n\n    # If compile CPython with `--disable-ipv6` option,\n    # we will get an (int, bytes) tuple, instead of a Exception.\n    async def unknown_addrinfo(*args: Any, **kwargs: Any) -> List[Any]:\n        return [\n            (\n                socket.AF_INET6,\n                socket.SOCK_STREAM,\n                6,\n                \"\",\n                (10, b\"\\x01\\xbb\\x00\\x00\\x00\\x00*\\x04NB\\x00\\x1a\\x00\\x00\"),\n            )\n        ]\n\n    loop.getaddrinfo = unknown_addrinfo\n    resolver = ThreadedResolver()\n    resolver._loop = loop\n    with patch(\"socket.has_ipv6\", False):\n        res = await resolver.resolve(\"www.python.org\")\n    assert len(res) == 0\n\n\nasync def test_close_for_threaded_resolver(loop) -> None:\n    resolver = ThreadedResolver()\n    await resolver.close()\n\n\n@pytest.mark.skipif(aiodns is None, reason=\"aiodns required\")\nasync def test_close_for_async_resolver(loop) -> None:\n    resolver = AsyncResolver(loop=loop)\n    await resolver.close()\n\n\nasync def test_default_loop_for_threaded_resolver(loop) -> None:\n    asyncio.set_event_loop(loop)\n    resolver = ThreadedResolver()\n    assert resolver._loop is loop\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_ipv6_positive_lookup(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv6_result([\"::1\"])\n        resolver = AsyncResolver()\n        real = await resolver.resolve(\"www.python.org\")\n        ipaddress.ip_address(real[0][\"host\"])\n        mock().getaddrinfo.assert_called_with(\n            \"www.python.org\",\n            family=socket.AF_INET,\n            flags=socket.AI_ADDRCONFIG,\n            port=0,\n            type=socket.SOCK_STREAM,\n        )\n\n\n@pytest.mark.skipif(aiodns is None, reason=\"aiodns required\")\nasync def test_async_resolver_query_ipv6_positive_lookup(loop) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        del mock().gethostbyname\n        mock().query.return_value = fake_query_result([\"::1\"])\n        resolver = AsyncResolver(loop=loop)\n        real = await resolver.resolve(\"www.python.org\", family=socket.AF_INET6)\n        ipaddress.ip_address(real[0][\"host\"])\n        mock().query.assert_called_with(\"www.python.org\", \"AAAA\")\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_error_messages_passed(\n    loop: asyncio.AbstractEventLoop,\n) -> None:\n    \"\"\"Ensure error messages are passed through from aiodns.\"\"\"\n    with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:\n        mock().getaddrinfo.side_effect = aiodns.error.DNSError(1, \"Test error message\")\n        resolver = AsyncResolver()\n        with pytest.raises(OSError, match=\"Test error message\") as excinfo:\n            await resolver.resolve(\"x.org\")\n\n        assert excinfo.value.strerror == \"Test error message\"\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_error_messages_passed_no_hosts(\n    loop: asyncio.AbstractEventLoop,\n) -> None:\n    \"\"\"Ensure error messages are passed through from aiodns.\"\"\"\n    with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv6_result([])\n        resolver = AsyncResolver()\n        with pytest.raises(OSError, match=\"DNS lookup failed\") as excinfo:\n            await resolver.resolve(\"x.org\")\n\n        assert excinfo.value.strerror == \"DNS lookup failed\"\n\n\nasync def test_async_resolver_aiodns_not_present(loop: Any, monkeypatch: Any) -> None:\n    monkeypatch.setattr(\"aiohttp.resolver.aiodns\", None)\n    with pytest.raises(RuntimeError):\n        AsyncResolver(loop=loop)\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\ndef test_aio_dns_is_default() -> None:\n    assert DefaultResolver is AsyncResolver\n\n\n@pytest.mark.skipif(getaddrinfo, reason=\"aiodns <3.2.0 required\")\ndef test_threaded_resolver_is_default() -> None:\n    assert DefaultResolver is ThreadedResolver\n",
            "new_file_content": "import asyncio\nimport ipaddress\nimport socket\nfrom ipaddress import ip_address\nfrom typing import Any, Awaitable, Callable, Collection, List, NamedTuple, Tuple, Union\nfrom unittest.mock import Mock, create_autospec, patch\n\nimport pytest\n\nfrom aiohttp.resolver import (\n    _NAME_SOCKET_FLAGS,\n    _SUPPORTS_SCOPE_ID,\n    AsyncResolver,\n    DefaultResolver,\n    ThreadedResolver,\n)\n\ntry:\n    import aiodns\n\n    getaddrinfo: Any = hasattr(aiodns.DNSResolver, \"getaddrinfo\")\nexcept ImportError:\n    aiodns = None  # type: ignore[assignment]\n    getaddrinfo = False\n\n\nclass FakeAIODNSAddrInfoNode(NamedTuple):\n\n    family: int\n    addr: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]]\n\n\nclass FakeAIODNSAddrInfoIPv4Result:\n    def __init__(self, hosts: Collection[str]) -> None:\n        self.nodes = [\n            FakeAIODNSAddrInfoNode(socket.AF_INET, (h.encode(), 0)) for h in hosts\n        ]\n\n\nclass FakeAIODNSAddrInfoIPv6Result:\n    def __init__(self, hosts: Collection[str]) -> None:\n        self.nodes = [\n            FakeAIODNSAddrInfoNode(\n                socket.AF_INET6,\n                (h.encode(), 0, 0, 3 if ip_address(h).is_link_local else 0),\n            )\n            for h in hosts\n        ]\n\n\nclass FakeAIODNSNameInfoIPv6Result:\n    def __init__(self, host: str) -> None:\n        self.node = host\n        self.service = None\n\n\nclass FakeQueryResult:\n    def __init__(self, host):\n        self.host = host\n\n\nasync def fake_aiodns_getaddrinfo_ipv4_result(\n    hosts: Collection[str],\n) -> FakeAIODNSAddrInfoIPv4Result:\n    return FakeAIODNSAddrInfoIPv4Result(hosts=hosts)\n\n\nasync def fake_aiodns_getaddrinfo_ipv6_result(\n    hosts: Collection[str],\n) -> FakeAIODNSAddrInfoIPv6Result:\n    return FakeAIODNSAddrInfoIPv6Result(hosts=hosts)\n\n\nasync def fake_aiodns_getnameinfo_ipv6_result(\n    host: str,\n) -> FakeAIODNSNameInfoIPv6Result:\n    return FakeAIODNSNameInfoIPv6Result(host)\n\n\nasync def fake_query_result(result):\n    return [FakeQueryResult(host=h) for h in result]\n\n\ndef fake_addrinfo(hosts: Collection[str]) -> Callable[..., Awaitable[Any]]:\n    async def fake(*args: Any, **kwargs: Any) -> List[Any]:\n        if not hosts:\n            raise socket.gaierror\n\n        return [(socket.AF_INET, None, socket.SOCK_STREAM, None, [h, 0]) for h in hosts]\n\n    return fake\n\n\ndef fake_ipv6_addrinfo(hosts: Collection[str]) -> Callable[..., Awaitable[Any]]:\n    async def fake(*args: Any, **kwargs: Any) -> List[Any]:\n        if not hosts:\n            raise socket.gaierror\n\n        return [\n            (\n                socket.AF_INET6,\n                None,\n                socket.SOCK_STREAM,\n                None,\n                (h, 0, 0, 3 if ip_address(h).is_link_local else 0),\n            )\n            for h in hosts\n        ]\n\n    return fake\n\n\ndef fake_ipv6_nameinfo(host: str) -> Callable[..., Awaitable[Any]]:\n    async def fake(*args: Any, **kwargs: Any) -> Tuple[str, int]:\n        return host, 0\n\n    return fake\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_positive_ipv4_lookup(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv4_result(\n            [\"127.0.0.1\"]\n        )\n        resolver = AsyncResolver()\n        real = await resolver.resolve(\"www.python.org\")\n        ipaddress.ip_address(real[0][\"host\"])\n        mock().getaddrinfo.assert_called_with(\n            \"www.python.org\",\n            family=socket.AF_INET,\n            flags=socket.AI_ADDRCONFIG,\n            port=0,\n            type=socket.SOCK_STREAM,\n        )\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\n@pytest.mark.skipif(\n    not _SUPPORTS_SCOPE_ID, reason=\"python version does not support scope id\"\n)\nasync def test_async_resolver_positive_link_local_ipv6_lookup(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv6_result(\n            [\"fe80::1\"]\n        )\n        mock().getnameinfo.return_value = fake_aiodns_getnameinfo_ipv6_result(\n            \"fe80::1%eth0\"\n        )\n        resolver = AsyncResolver()\n        real = await resolver.resolve(\"www.python.org\")\n        ipaddress.ip_address(real[0][\"host\"])\n        mock().getaddrinfo.assert_called_with(\n            \"www.python.org\",\n            family=socket.AF_INET,\n            flags=socket.AI_ADDRCONFIG,\n            port=0,\n            type=socket.SOCK_STREAM,\n        )\n        mock().getnameinfo.assert_called_with((\"fe80::1\", 0, 0, 3), _NAME_SOCKET_FLAGS)\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_multiple_replies(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        ips = [\"127.0.0.1\", \"127.0.0.2\", \"127.0.0.3\", \"127.0.0.4\"]\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv4_result(ips)\n        resolver = AsyncResolver()\n        real = await resolver.resolve(\"www.google.com\")\n        ips = [ipaddress.ip_address(x[\"host\"]) for x in real]\n        assert len(ips) > 3, \"Expecting multiple addresses\"\n\n\n@pytest.mark.skipif(aiodns is None, reason=\"aiodns required\")\nasync def test_async_resolver_query_multiple_replies(loop) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        del mock().gethostbyname\n        ips = [\"127.0.0.1\", \"127.0.0.2\", \"127.0.0.3\", \"127.0.0.4\"]\n        mock().query.return_value = fake_query_result(ips)\n        resolver = AsyncResolver(loop=loop)\n        real = await resolver.resolve(\"www.google.com\")\n        ips = [ipaddress.ip_address(x[\"host\"]) for x in real]\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_negative_lookup(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        mock().getaddrinfo.side_effect = aiodns.error.DNSError()\n        resolver = AsyncResolver()\n        with pytest.raises(OSError):\n            await resolver.resolve(\"doesnotexist.bla\")\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_no_hosts_in_getaddrinfo(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv4_result([])\n        resolver = AsyncResolver()\n        with pytest.raises(OSError):\n            await resolver.resolve(\"doesnotexist.bla\")\n\n\nasync def test_threaded_resolver_positive_lookup() -> None:\n    loop = Mock()\n    loop.getaddrinfo = fake_addrinfo([\"127.0.0.1\"])\n    resolver = ThreadedResolver(loop=loop)\n    real = await resolver.resolve(\"www.python.org\")\n    assert real[0][\"hostname\"] == \"www.python.org\"\n    ipaddress.ip_address(real[0][\"host\"])\n\n\n@pytest.mark.skipif(\n    not _SUPPORTS_SCOPE_ID, reason=\"python version does not support scope id\"\n)\nasync def test_threaded_resolver_positive_ipv6_link_local_lookup() -> None:\n    loop = Mock()\n    loop.getaddrinfo = fake_ipv6_addrinfo([\"fe80::1\"])\n    loop.getnameinfo = fake_ipv6_nameinfo(\"fe80::1%eth0\")\n\n    # Mock the fake function that was returned by helper functions\n    loop.getaddrinfo = create_autospec(loop.getaddrinfo)\n    loop.getnameinfo = create_autospec(loop.getnameinfo)\n\n    # Set the correct return values for mock functions\n    loop.getaddrinfo.return_value = await fake_ipv6_addrinfo([\"fe80::1\"])()\n    loop.getnameinfo.return_value = await fake_ipv6_nameinfo(\"fe80::1%eth0\")()\n\n    resolver = ThreadedResolver()\n    resolver._loop = loop\n    real = await resolver.resolve(\"www.python.org\")\n    assert real[0][\"hostname\"] == \"www.python.org\"\n    ipaddress.ip_address(real[0][\"host\"])\n\n    loop.getaddrinfo.assert_called_with(\n        \"www.python.org\",\n        0,\n        type=socket.SOCK_STREAM,\n        family=socket.AF_INET,\n        flags=socket.AI_ADDRCONFIG,\n    )\n\n    loop.getnameinfo.assert_called_with((\"fe80::1\", 0, 0, 3), _NAME_SOCKET_FLAGS)\n\n\nasync def test_threaded_resolver_multiple_replies() -> None:\n    loop = Mock()\n    ips = [\"127.0.0.1\", \"127.0.0.2\", \"127.0.0.3\", \"127.0.0.4\"]\n    loop.getaddrinfo = fake_addrinfo(ips)\n    resolver = ThreadedResolver(loop=loop)\n    real = await resolver.resolve(\"www.google.com\")\n    ips = [ipaddress.ip_address(x[\"host\"]) for x in real]\n    assert len(ips) > 3, \"Expecting multiple addresses\"\n\n\nasync def test_threaded_negative_lookup() -> None:\n    loop = Mock()\n    ips = []\n    loop.getaddrinfo = fake_addrinfo(ips)\n    resolver = ThreadedResolver(loop=loop)\n    with pytest.raises(socket.gaierror):\n        await resolver.resolve(\"doesnotexist.bla\")\n\n\nasync def test_threaded_negative_ipv6_lookup() -> None:\n    loop = Mock()\n    ips: List[Any] = []\n    loop.getaddrinfo = fake_ipv6_addrinfo(ips)\n    resolver = ThreadedResolver()\n    resolver._loop = loop\n    with pytest.raises(socket.gaierror):\n        await resolver.resolve(\"doesnotexist.bla\")\n\n\nasync def test_threaded_negative_lookup_with_unknown_result() -> None:\n    loop = Mock()\n\n    # If compile CPython with `--disable-ipv6` option,\n    # we will get an (int, bytes) tuple, instead of a Exception.\n    async def unknown_addrinfo(*args: Any, **kwargs: Any) -> List[Any]:\n        return [\n            (\n                socket.AF_INET6,\n                socket.SOCK_STREAM,\n                6,\n                \"\",\n                (10, b\"\\x01\\xbb\\x00\\x00\\x00\\x00*\\x04NB\\x00\\x1a\\x00\\x00\"),\n            )\n        ]\n\n    loop.getaddrinfo = unknown_addrinfo\n    resolver = ThreadedResolver()\n    resolver._loop = loop\n    with patch(\"socket.has_ipv6\", False):\n        res = await resolver.resolve(\"www.python.org\")\n    assert len(res) == 0\n\n\nasync def test_close_for_threaded_resolver(loop) -> None:\n    resolver = ThreadedResolver()\n    await resolver.close()\n\n\n@pytest.mark.skipif(aiodns is None, reason=\"aiodns required\")\nasync def test_close_for_async_resolver(loop) -> None:\n    resolver = AsyncResolver(loop=loop)\n    await resolver.close()\n\n\nasync def test_default_loop_for_threaded_resolver(loop) -> None:\n    asyncio.set_event_loop(loop)\n    resolver = ThreadedResolver()\n    assert resolver._loop is loop\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_ipv6_positive_lookup(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv6_result([\"::1\"])\n        resolver = AsyncResolver()\n        real = await resolver.resolve(\"www.python.org\")\n        ipaddress.ip_address(real[0][\"host\"])\n        mock().getaddrinfo.assert_called_with(\n            \"www.python.org\",\n            family=socket.AF_INET,\n            flags=socket.AI_ADDRCONFIG,\n            port=0,\n            type=socket.SOCK_STREAM,\n        )\n\n\n@pytest.mark.skipif(aiodns is None, reason=\"aiodns required\")\nasync def test_async_resolver_query_ipv6_positive_lookup(loop) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        del mock().gethostbyname\n        mock().query.return_value = fake_query_result([\"::1\"])\n        resolver = AsyncResolver(loop=loop)\n        real = await resolver.resolve(\"www.python.org\", family=socket.AF_INET6)\n        ipaddress.ip_address(real[0][\"host\"])\n        mock().query.assert_called_with(\"www.python.org\", \"AAAA\")\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_query_fallback_error_messages_passed(\n    loop: asyncio.AbstractEventLoop,\n) -> None:\n    \"\"\"Ensure error messages are passed through from aiodns with query fallback.\"\"\"\n    with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:\n        del mock().gethostbyname\n        mock().query.side_effect = aiodns.error.DNSError(1, \"Test error message\")\n        resolver = AsyncResolver()\n        with pytest.raises(OSError, match=\"Test error message\") as excinfo:\n            await resolver.resolve(\"x.org\")\n\n        assert excinfo.value.strerror == \"Test error message\"\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_query_fallback_error_messages_passed_no_hosts(\n    loop: asyncio.AbstractEventLoop,\n) -> None:\n    \"\"\"Ensure error messages are passed through from aiodns with query fallback.\"\"\"\n    with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:\n        del mock().gethostbyname\n        mock().query.return_value = fake_query_result([])\n        resolver = AsyncResolver()\n        with pytest.raises(OSError, match=\"DNS lookup failed\") as excinfo:\n            await resolver.resolve(\"x.org\")\n\n        assert excinfo.value.strerror == \"DNS lookup failed\"\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_error_messages_passed(\n    loop: asyncio.AbstractEventLoop,\n) -> None:\n    \"\"\"Ensure error messages are passed through from aiodns.\"\"\"\n    with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:\n        mock().getaddrinfo.side_effect = aiodns.error.DNSError(1, \"Test error message\")\n        resolver = AsyncResolver()\n        with pytest.raises(OSError, match=\"Test error message\") as excinfo:\n            await resolver.resolve(\"x.org\")\n\n        assert excinfo.value.strerror == \"Test error message\"\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_error_messages_passed_no_hosts(\n    loop: asyncio.AbstractEventLoop,\n) -> None:\n    \"\"\"Ensure error messages are passed through from aiodns.\"\"\"\n    with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv6_result([])\n        resolver = AsyncResolver()\n        with pytest.raises(OSError, match=\"DNS lookup failed\") as excinfo:\n            await resolver.resolve(\"x.org\")\n\n        assert excinfo.value.strerror == \"DNS lookup failed\"\n\n\nasync def test_async_resolver_aiodns_not_present(loop: Any, monkeypatch: Any) -> None:\n    monkeypatch.setattr(\"aiohttp.resolver.aiodns\", None)\n    with pytest.raises(RuntimeError):\n        AsyncResolver(loop=loop)\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\ndef test_aio_dns_is_default() -> None:\n    assert DefaultResolver is AsyncResolver\n\n\n@pytest.mark.skipif(getaddrinfo, reason=\"aiodns <3.2.0 required\")\ndef test_threaded_resolver_is_default() -> None:\n    assert DefaultResolver is ThreadedResolver\n",
            "header": {
                "file": {
                    "path": "tests/test_resolver.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "6322bcfc",
                "new_commit_hash": "f8fba501",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/tests/test_resolver.py"
            },
            "plus_file": {
                "path": "b/tests/test_resolver.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 339,
                            "length": 6
                        },
                        "new_range": {
                            "start": 339,
                            "length": 36
                        },
                        "section": "async def test_async_resolver_query_ipv6_positive_lookup(loop) -> None:"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        mock().query.assert_called_with(\"www.python.org\", \"AAAA\")",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")",
                                "type": "added"
                            },
                            {
                                "content": "async def test_async_resolver_query_fallback_error_messages_passed(",
                                "type": "added"
                            },
                            {
                                "content": "    loop: asyncio.AbstractEventLoop,",
                                "type": "added"
                            },
                            {
                                "content": ") -> None:",
                                "type": "added"
                            },
                            {
                                "content": "    \"\"\"Ensure error messages are passed through from aiodns with query fallback.\"\"\"",
                                "type": "added"
                            },
                            {
                                "content": "    with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:",
                                "type": "added"
                            },
                            {
                                "content": "        del mock().gethostbyname",
                                "type": "added"
                            },
                            {
                                "content": "        mock().query.side_effect = aiodns.error.DNSError(1, \"Test error message\")",
                                "type": "added"
                            },
                            {
                                "content": "        resolver = AsyncResolver()",
                                "type": "added"
                            },
                            {
                                "content": "        with pytest.raises(OSError, match=\"Test error message\") as excinfo:",
                                "type": "added"
                            },
                            {
                                "content": "            await resolver.resolve(\"x.org\")",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "        assert excinfo.value.strerror == \"Test error message\"",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")",
                                "type": "added"
                            },
                            {
                                "content": "async def test_async_resolver_query_fallback_error_messages_passed_no_hosts(",
                                "type": "added"
                            },
                            {
                                "content": "    loop: asyncio.AbstractEventLoop,",
                                "type": "added"
                            },
                            {
                                "content": ") -> None:",
                                "type": "added"
                            },
                            {
                                "content": "    \"\"\"Ensure error messages are passed through from aiodns with query fallback.\"\"\"",
                                "type": "added"
                            },
                            {
                                "content": "    with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:",
                                "type": "added"
                            },
                            {
                                "content": "        del mock().gethostbyname",
                                "type": "added"
                            },
                            {
                                "content": "        mock().query.return_value = fake_query_result([])",
                                "type": "added"
                            },
                            {
                                "content": "        resolver = AsyncResolver()",
                                "type": "added"
                            },
                            {
                                "content": "        with pytest.raises(OSError, match=\"DNS lookup failed\") as excinfo:",
                                "type": "added"
                            },
                            {
                                "content": "            await resolver.resolve(\"x.org\")",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "        assert excinfo.value.strerror == \"DNS lookup failed\"",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")",
                                "type": "context"
                            },
                            {
                                "content": "async def test_async_resolver_error_messages_passed(",
                                "type": "context"
                            },
                            {
                                "content": "    loop: asyncio.AbstractEventLoop,",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [],
                    "added_entities": [
                        {
                            "file_name": "tests/test_resolver.py",
                            "type": "function",
                            "name": "test_async_resolver_query_fallback_error_messages_passed_no_hosts",
                            "content": "async def test_async_resolver_query_fallback_error_messages_passed_no_hosts(\n    loop: asyncio.AbstractEventLoop,\n) -> None:\n    \"\"\"Ensure error messages are passed through from aiodns with query fallback.\"\"\"\n    with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:\n        del mock().gethostbyname\n        mock().query.return_value = fake_query_result([])\n        resolver = AsyncResolver()\n        with pytest.raises(OSError, match=\"DNS lookup failed\") as excinfo:\n            await resolver.resolve(\"x.org\")\n\n        assert excinfo.value.strerror == \"DNS lookup failed\"",
                            "ast_type_str": "AsyncFunctionDef",
                            "start_lineno": 358,
                            "end_lineno": 369,
                            "parent": null
                        },
                        {
                            "file_name": "tests/test_resolver.py",
                            "type": "function",
                            "name": "test_async_resolver_query_fallback_error_messages_passed",
                            "content": "async def test_async_resolver_query_fallback_error_messages_passed(\n    loop: asyncio.AbstractEventLoop,\n) -> None:\n    \"\"\"Ensure error messages are passed through from aiodns with query fallback.\"\"\"\n    with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:\n        del mock().gethostbyname\n        mock().query.side_effect = aiodns.error.DNSError(1, \"Test error message\")\n        resolver = AsyncResolver()\n        with pytest.raises(OSError, match=\"Test error message\") as excinfo:\n            await resolver.resolve(\"x.org\")\n\n        assert excinfo.value.strerror == \"Test error message\"",
                            "ast_type_str": "AsyncFunctionDef",
                            "start_lineno": 343,
                            "end_lineno": 354,
                            "parent": null
                        }
                    ],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "ee87a049be63887c0a5d9f4e6008b4e47460f16c^",
    "new_commit_hash": "ee87a049be63887c0a5d9f4e6008b4e47460f16c",
    "commit_message": "[PR #9455/dfaafac0 backport][3.10] Fix AsyncResolver query fallback swallowing the error message (#9456)\n\nCo-authored-by: J. Nick Koston <nick@koston.org>",
    "commit_date": "2024-10-10T11:21:57-05:00",
    "metadata": {}
}
{
    "repo_name": "aiohttp",
    "new_commit_hash": "ee87a049be63887c0a5d9f4e6008b4e47460f16c",
    "test_file_codes": [
        "import asyncio\nimport ipaddress\nimport socket\nfrom ipaddress import ip_address\nfrom typing import Any, Awaitable, Callable, Collection, List, NamedTuple, Tuple, Union\nfrom unittest.mock import Mock, create_autospec, patch\n\nimport pytest\n\nfrom aiohttp.resolver import (\n    _NAME_SOCKET_FLAGS,\n    _SUPPORTS_SCOPE_ID,\n    AsyncResolver,\n    DefaultResolver,\n    ThreadedResolver,\n)\n\ntry:\n    import aiodns\n\n    getaddrinfo: Any = hasattr(aiodns.DNSResolver, \"getaddrinfo\")\nexcept ImportError:\n    aiodns = None  # type: ignore[assignment]\n    getaddrinfo = False\n\n\nclass FakeAIODNSAddrInfoNode(NamedTuple):\n\n    family: int\n    addr: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]]\n\n\nclass FakeAIODNSAddrInfoIPv4Result:\n    def __init__(self, hosts: Collection[str]) -> None:\n        self.nodes = [\n            FakeAIODNSAddrInfoNode(socket.AF_INET, (h.encode(), 0)) for h in hosts\n        ]\n\n\nclass FakeAIODNSAddrInfoIPv6Result:\n    def __init__(self, hosts: Collection[str]) -> None:\n        self.nodes = [\n            FakeAIODNSAddrInfoNode(\n                socket.AF_INET6,\n                (h.encode(), 0, 0, 3 if ip_address(h).is_link_local else 0),\n            )\n            for h in hosts\n        ]\n\n\nclass FakeAIODNSNameInfoIPv6Result:\n    def __init__(self, host: str) -> None:\n        self.node = host\n        self.service = None\n\n\nclass FakeQueryResult:\n    def __init__(self, host):\n        self.host = host\n\n\nasync def fake_aiodns_getaddrinfo_ipv4_result(\n    hosts: Collection[str],\n) -> FakeAIODNSAddrInfoIPv4Result:\n    return FakeAIODNSAddrInfoIPv4Result(hosts=hosts)\n\n\nasync def fake_aiodns_getaddrinfo_ipv6_result(\n    hosts: Collection[str],\n) -> FakeAIODNSAddrInfoIPv6Result:\n    return FakeAIODNSAddrInfoIPv6Result(hosts=hosts)\n\n\nasync def fake_aiodns_getnameinfo_ipv6_result(\n    host: str,\n) -> FakeAIODNSNameInfoIPv6Result:\n    return FakeAIODNSNameInfoIPv6Result(host)\n\n\nasync def fake_query_result(result):\n    return [FakeQueryResult(host=h) for h in result]\n\n\ndef fake_addrinfo(hosts: Collection[str]) -> Callable[..., Awaitable[Any]]:\n    async def fake(*args: Any, **kwargs: Any) -> List[Any]:\n        if not hosts:\n            raise socket.gaierror\n\n        return [(socket.AF_INET, None, socket.SOCK_STREAM, None, [h, 0]) for h in hosts]\n\n    return fake\n\n\ndef fake_ipv6_addrinfo(hosts: Collection[str]) -> Callable[..., Awaitable[Any]]:\n    async def fake(*args: Any, **kwargs: Any) -> List[Any]:\n        if not hosts:\n            raise socket.gaierror\n\n        return [\n            (\n                socket.AF_INET6,\n                None,\n                socket.SOCK_STREAM,\n                None,\n                (h, 0, 0, 3 if ip_address(h).is_link_local else 0),\n            )\n            for h in hosts\n        ]\n\n    return fake\n\n\ndef fake_ipv6_nameinfo(host: str) -> Callable[..., Awaitable[Any]]:\n    async def fake(*args: Any, **kwargs: Any) -> Tuple[str, int]:\n        return host, 0\n\n    return fake\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_positive_ipv4_lookup(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv4_result(\n            [\"127.0.0.1\"]\n        )\n        resolver = AsyncResolver()\n        real = await resolver.resolve(\"www.python.org\")\n        ipaddress.ip_address(real[0][\"host\"])\n        mock().getaddrinfo.assert_called_with(\n            \"www.python.org\",\n            family=socket.AF_INET,\n            flags=socket.AI_ADDRCONFIG,\n            port=0,\n            type=socket.SOCK_STREAM,\n        )\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\n@pytest.mark.skipif(\n    not _SUPPORTS_SCOPE_ID, reason=\"python version does not support scope id\"\n)\nasync def test_async_resolver_positive_link_local_ipv6_lookup(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv6_result(\n            [\"fe80::1\"]\n        )\n        mock().getnameinfo.return_value = fake_aiodns_getnameinfo_ipv6_result(\n            \"fe80::1%eth0\"\n        )\n        resolver = AsyncResolver()\n        real = await resolver.resolve(\"www.python.org\")\n        ipaddress.ip_address(real[0][\"host\"])\n        mock().getaddrinfo.assert_called_with(\n            \"www.python.org\",\n            family=socket.AF_INET,\n            flags=socket.AI_ADDRCONFIG,\n            port=0,\n            type=socket.SOCK_STREAM,\n        )\n        mock().getnameinfo.assert_called_with((\"fe80::1\", 0, 0, 3), _NAME_SOCKET_FLAGS)\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_multiple_replies(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        ips = [\"127.0.0.1\", \"127.0.0.2\", \"127.0.0.3\", \"127.0.0.4\"]\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv4_result(ips)\n        resolver = AsyncResolver()\n        real = await resolver.resolve(\"www.google.com\")\n        ips = [ipaddress.ip_address(x[\"host\"]) for x in real]\n        assert len(ips) > 3, \"Expecting multiple addresses\"\n\n\n@pytest.mark.skipif(aiodns is None, reason=\"aiodns required\")\nasync def test_async_resolver_query_multiple_replies(loop) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        del mock().gethostbyname\n        ips = [\"127.0.0.1\", \"127.0.0.2\", \"127.0.0.3\", \"127.0.0.4\"]\n        mock().query.return_value = fake_query_result(ips)\n        resolver = AsyncResolver(loop=loop)\n        real = await resolver.resolve(\"www.google.com\")\n        ips = [ipaddress.ip_address(x[\"host\"]) for x in real]\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_negative_lookup(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        mock().getaddrinfo.side_effect = aiodns.error.DNSError()\n        resolver = AsyncResolver()\n        with pytest.raises(OSError):\n            await resolver.resolve(\"doesnotexist.bla\")\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_no_hosts_in_getaddrinfo(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv4_result([])\n        resolver = AsyncResolver()\n        with pytest.raises(OSError):\n            await resolver.resolve(\"doesnotexist.bla\")\n\n\nasync def test_threaded_resolver_positive_lookup() -> None:\n    loop = Mock()\n    loop.getaddrinfo = fake_addrinfo([\"127.0.0.1\"])\n    resolver = ThreadedResolver(loop=loop)\n    real = await resolver.resolve(\"www.python.org\")\n    assert real[0][\"hostname\"] == \"www.python.org\"\n    ipaddress.ip_address(real[0][\"host\"])\n\n\n@pytest.mark.skipif(\n    not _SUPPORTS_SCOPE_ID, reason=\"python version does not support scope id\"\n)\nasync def test_threaded_resolver_positive_ipv6_link_local_lookup() -> None:\n    loop = Mock()\n    loop.getaddrinfo = fake_ipv6_addrinfo([\"fe80::1\"])\n    loop.getnameinfo = fake_ipv6_nameinfo(\"fe80::1%eth0\")\n\n    # Mock the fake function that was returned by helper functions\n    loop.getaddrinfo = create_autospec(loop.getaddrinfo)\n    loop.getnameinfo = create_autospec(loop.getnameinfo)\n\n    # Set the correct return values for mock functions\n    loop.getaddrinfo.return_value = await fake_ipv6_addrinfo([\"fe80::1\"])()\n    loop.getnameinfo.return_value = await fake_ipv6_nameinfo(\"fe80::1%eth0\")()\n\n    resolver = ThreadedResolver()\n    resolver._loop = loop\n    real = await resolver.resolve(\"www.python.org\")\n    assert real[0][\"hostname\"] == \"www.python.org\"\n    ipaddress.ip_address(real[0][\"host\"])\n\n    loop.getaddrinfo.assert_called_with(\n        \"www.python.org\",\n        0,\n        type=socket.SOCK_STREAM,\n        family=socket.AF_INET,\n        flags=socket.AI_ADDRCONFIG,\n    )\n\n    loop.getnameinfo.assert_called_with((\"fe80::1\", 0, 0, 3), _NAME_SOCKET_FLAGS)\n\n\nasync def test_threaded_resolver_multiple_replies() -> None:\n    loop = Mock()\n    ips = [\"127.0.0.1\", \"127.0.0.2\", \"127.0.0.3\", \"127.0.0.4\"]\n    loop.getaddrinfo = fake_addrinfo(ips)\n    resolver = ThreadedResolver(loop=loop)\n    real = await resolver.resolve(\"www.google.com\")\n    ips = [ipaddress.ip_address(x[\"host\"]) for x in real]\n    assert len(ips) > 3, \"Expecting multiple addresses\"\n\n\nasync def test_threaded_negative_lookup() -> None:\n    loop = Mock()\n    ips = []\n    loop.getaddrinfo = fake_addrinfo(ips)\n    resolver = ThreadedResolver(loop=loop)\n    with pytest.raises(socket.gaierror):\n        await resolver.resolve(\"doesnotexist.bla\")\n\n\nasync def test_threaded_negative_ipv6_lookup() -> None:\n    loop = Mock()\n    ips: List[Any] = []\n    loop.getaddrinfo = fake_ipv6_addrinfo(ips)\n    resolver = ThreadedResolver()\n    resolver._loop = loop\n    with pytest.raises(socket.gaierror):\n        await resolver.resolve(\"doesnotexist.bla\")\n\n\nasync def test_threaded_negative_lookup_with_unknown_result() -> None:\n    loop = Mock()\n\n    # If compile CPython with `--disable-ipv6` option,\n    # we will get an (int, bytes) tuple, instead of a Exception.\n    async def unknown_addrinfo(*args: Any, **kwargs: Any) -> List[Any]:\n        return [\n            (\n                socket.AF_INET6,\n                socket.SOCK_STREAM,\n                6,\n                \"\",\n                (10, b\"\\x01\\xbb\\x00\\x00\\x00\\x00*\\x04NB\\x00\\x1a\\x00\\x00\"),\n            )\n        ]\n\n    loop.getaddrinfo = unknown_addrinfo\n    resolver = ThreadedResolver()\n    resolver._loop = loop\n    with patch(\"socket.has_ipv6\", False):\n        res = await resolver.resolve(\"www.python.org\")\n    assert len(res) == 0\n\n\nasync def test_close_for_threaded_resolver(loop) -> None:\n    resolver = ThreadedResolver()\n    await resolver.close()\n\n\n@pytest.mark.skipif(aiodns is None, reason=\"aiodns required\")\nasync def test_close_for_async_resolver(loop) -> None:\n    resolver = AsyncResolver(loop=loop)\n    await resolver.close()\n\n\nasync def test_default_loop_for_threaded_resolver(loop) -> None:\n    asyncio.set_event_loop(loop)\n    resolver = ThreadedResolver()\n    assert resolver._loop is loop\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_ipv6_positive_lookup(loop: Any) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv6_result([\"::1\"])\n        resolver = AsyncResolver()\n        real = await resolver.resolve(\"www.python.org\")\n        ipaddress.ip_address(real[0][\"host\"])\n        mock().getaddrinfo.assert_called_with(\n            \"www.python.org\",\n            family=socket.AF_INET,\n            flags=socket.AI_ADDRCONFIG,\n            port=0,\n            type=socket.SOCK_STREAM,\n        )\n\n\n@pytest.mark.skipif(aiodns is None, reason=\"aiodns required\")\nasync def test_async_resolver_query_ipv6_positive_lookup(loop) -> None:\n    with patch(\"aiodns.DNSResolver\") as mock:\n        del mock().gethostbyname\n        mock().query.return_value = fake_query_result([\"::1\"])\n        resolver = AsyncResolver(loop=loop)\n        real = await resolver.resolve(\"www.python.org\", family=socket.AF_INET6)\n        ipaddress.ip_address(real[0][\"host\"])\n        mock().query.assert_called_with(\"www.python.org\", \"AAAA\")\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_query_fallback_error_messages_passed(\n    loop: asyncio.AbstractEventLoop,\n) -> None:\n    \"\"\"Ensure error messages are passed through from aiodns with query fallback.\"\"\"\n    with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:\n        del mock().gethostbyname\n        mock().query.side_effect = aiodns.error.DNSError(1, \"Test error message\")\n        resolver = AsyncResolver()\n        with pytest.raises(OSError, match=\"Test error message\") as excinfo:\n            await resolver.resolve(\"x.org\")\n\n        assert excinfo.value.strerror == \"Test error message\"\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_query_fallback_error_messages_passed_no_hosts(\n    loop: asyncio.AbstractEventLoop,\n) -> None:\n    \"\"\"Ensure error messages are passed through from aiodns with query fallback.\"\"\"\n    with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:\n        del mock().gethostbyname\n        mock().query.return_value = fake_query_result([])\n        resolver = AsyncResolver()\n        with pytest.raises(OSError, match=\"DNS lookup failed\") as excinfo:\n            await resolver.resolve(\"x.org\")\n\n        assert excinfo.value.strerror == \"DNS lookup failed\"\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_error_messages_passed(\n    loop: asyncio.AbstractEventLoop,\n) -> None:\n    \"\"\"Ensure error messages are passed through from aiodns.\"\"\"\n    with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:\n        mock().getaddrinfo.side_effect = aiodns.error.DNSError(1, \"Test error message\")\n        resolver = AsyncResolver()\n        with pytest.raises(OSError, match=\"Test error message\") as excinfo:\n            await resolver.resolve(\"x.org\")\n\n        assert excinfo.value.strerror == \"Test error message\"\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\nasync def test_async_resolver_error_messages_passed_no_hosts(\n    loop: asyncio.AbstractEventLoop,\n) -> None:\n    \"\"\"Ensure error messages are passed through from aiodns.\"\"\"\n    with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:\n        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv6_result([])\n        resolver = AsyncResolver()\n        with pytest.raises(OSError, match=\"DNS lookup failed\") as excinfo:\n            await resolver.resolve(\"x.org\")\n\n        assert excinfo.value.strerror == \"DNS lookup failed\"\n\n\nasync def test_async_resolver_aiodns_not_present(loop: Any, monkeypatch: Any) -> None:\n    monkeypatch.setattr(\"aiohttp.resolver.aiodns\", None)\n    with pytest.raises(RuntimeError):\n        AsyncResolver(loop=loop)\n\n\n@pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\ndef test_aio_dns_is_default() -> None:\n    assert DefaultResolver is AsyncResolver\n\n\n@pytest.mark.skipif(getaddrinfo, reason=\"aiodns <3.2.0 required\")\ndef test_threaded_resolver_is_default() -> None:\n    assert DefaultResolver is ThreadedResolver\n",
        "import asyncio\nimport base64\nimport os\nimport socket\nimport ssl\nimport sys\nfrom hashlib import md5, sha1, sha256\nfrom pathlib import Path\nfrom tempfile import TemporaryDirectory\nfrom typing import Any\nfrom unittest import mock\nfrom uuid import uuid4\n\nimport pytest\n\nfrom aiohttp.client_proto import ResponseHandler\nfrom aiohttp.http import WS_KEY\nfrom aiohttp.test_utils import loop_context\n\ntry:\n    import trustme\n\n    # Check if the CA is available in runtime, MacOS on Py3.10 fails somehow\n    trustme.CA()\n\n    TRUSTME: bool = True\nexcept ImportError:\n    TRUSTME = False\n\npytest_plugins = [\"aiohttp.pytest_plugin\", \"pytester\"]\n\nIS_HPUX = sys.platform.startswith(\"hp-ux\")\nIS_LINUX = sys.platform.startswith(\"linux\")\n\n\n@pytest.fixture\ndef tls_certificate_authority():\n    if not TRUSTME:\n        pytest.xfail(\"trustme is not supported\")\n    return trustme.CA()\n\n\n@pytest.fixture\ndef tls_certificate(tls_certificate_authority):\n    return tls_certificate_authority.issue_cert(\n        \"localhost\",\n        \"xn--prklad-4va.localhost\",\n        \"127.0.0.1\",\n        \"::1\",\n    )\n\n\n@pytest.fixture\ndef ssl_ctx(tls_certificate):\n    ssl_ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)\n    tls_certificate.configure_cert(ssl_ctx)\n    return ssl_ctx\n\n\n@pytest.fixture\ndef client_ssl_ctx(tls_certificate_authority):\n    ssl_ctx = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH)\n    tls_certificate_authority.configure_trust(ssl_ctx)\n    return ssl_ctx\n\n\n@pytest.fixture\ndef tls_ca_certificate_pem_path(tls_certificate_authority):\n    with tls_certificate_authority.cert_pem.tempfile() as ca_cert_pem:\n        yield ca_cert_pem\n\n\n@pytest.fixture\ndef tls_certificate_pem_path(tls_certificate):\n    with tls_certificate.private_key_and_cert_chain_pem.tempfile() as cert_pem:\n        yield cert_pem\n\n\n@pytest.fixture\ndef tls_certificate_pem_bytes(tls_certificate):\n    return tls_certificate.cert_chain_pems[0].bytes()\n\n\n@pytest.fixture\ndef tls_certificate_fingerprint_sha256(tls_certificate_pem_bytes):\n    tls_cert_der = ssl.PEM_cert_to_DER_cert(tls_certificate_pem_bytes.decode())\n    return sha256(tls_cert_der).digest()\n\n\n@pytest.fixture\ndef unix_sockname(tmp_path, tmp_path_factory):\n    \"\"\"Generate an fs path to the UNIX domain socket for testing.\n\n    N.B. Different OS kernels have different fs path length limitations\n    for it. For Linux, it's 108, for HP-UX it's 92 (or higher) depending\n    on its version. For for most of the BSDs (Open, Free, macOS) it's\n    mostly 104 but sometimes it can be down to 100.\n\n    Ref: https://github.com/aio-libs/aiohttp/issues/3572\n    \"\"\"\n    if not hasattr(socket, \"AF_UNIX\"):\n        pytest.skip(\"requires UNIX sockets\")\n\n    max_sock_len = 92 if IS_HPUX else 108 if IS_LINUX else 100\n    \"\"\"Amount of bytes allocated for the UNIX socket path by OS kernel.\n\n    Ref: https://unix.stackexchange.com/a/367012/27133\n    \"\"\"\n\n    sock_file_name = \"unix.sock\"\n    unique_prefix = f\"{uuid4()!s}-\"\n    unique_prefix_len = len(unique_prefix.encode())\n\n    root_tmp_dir = Path(\"/tmp\").resolve()\n    os_tmp_dir = Path(os.getenv(\"TMPDIR\", \"/tmp\")).resolve()\n    original_base_tmp_path = Path(\n        str(tmp_path_factory.getbasetemp()),\n    ).resolve()\n\n    original_base_tmp_path_hash = md5(\n        str(original_base_tmp_path).encode(),\n    ).hexdigest()\n\n    def make_tmp_dir(base_tmp_dir):\n        return TemporaryDirectory(\n            dir=str(base_tmp_dir),\n            prefix=\"pt-\",\n            suffix=f\"-{original_base_tmp_path_hash!s}\",\n        )\n\n    def assert_sock_fits(sock_path):\n        sock_path_len = len(sock_path.encode())\n        # exit-check to verify that it's correct and simplify debugging\n        # in the future\n        assert sock_path_len <= max_sock_len, (\n            \"Suggested UNIX socket ({sock_path}) is {sock_path_len} bytes \"\n            \"long but the current kernel only has {max_sock_len} bytes \"\n            \"allocated to hold it so it must be shorter. \"\n            \"See https://github.com/aio-libs/aiohttp/issues/3572 \"\n            \"for more info.\"\n        ).format_map(locals())\n\n    paths = original_base_tmp_path, os_tmp_dir, root_tmp_dir\n    unique_paths = [p for n, p in enumerate(paths) if p not in paths[:n]]\n    paths_num = len(unique_paths)\n\n    for num, tmp_dir_path in enumerate(paths, 1):\n        with make_tmp_dir(tmp_dir_path) as tmpd:\n            tmpd = Path(tmpd).resolve()\n            sock_path = str(tmpd / sock_file_name)\n            sock_path_len = len(sock_path.encode())\n\n            if num >= paths_num:\n                # exit-check to verify that it's correct and simplify\n                # debugging in the future\n                assert_sock_fits(sock_path)\n\n            if sock_path_len <= max_sock_len:\n                if max_sock_len - sock_path_len >= unique_prefix_len:\n                    # If we're lucky to have extra space in the path,\n                    # let's also make it more unique\n                    sock_path = str(tmpd / \"\".join((unique_prefix, sock_file_name)))\n                    # Double-checking it:\n                    assert_sock_fits(sock_path)\n                yield sock_path\n                return\n\n\n@pytest.fixture\ndef pipe_name():\n    name = rf\"\\\\.\\pipe\\{uuid4().hex}\"\n    return name\n\n\n@pytest.fixture\ndef create_mocked_conn(loop: Any):\n    def _proto_factory(conn_closing_result=None, **kwargs):\n        proto = mock.create_autospec(ResponseHandler, **kwargs)\n        proto.closed = loop.create_future()\n        proto.closed.set_result(conn_closing_result)\n        return proto\n\n    yield _proto_factory\n\n\n@pytest.fixture\ndef selector_loop():\n    policy = asyncio.WindowsSelectorEventLoopPolicy()\n    asyncio.set_event_loop_policy(policy)\n\n    with loop_context(policy.new_event_loop) as _loop:\n        asyncio.set_event_loop(_loop)\n        yield _loop\n\n\n@pytest.fixture\ndef netrc_contents(\n    tmp_path: Path,\n    monkeypatch: pytest.MonkeyPatch,\n    request: pytest.FixtureRequest,\n):\n    \"\"\"\n    Prepare :file:`.netrc` with given contents.\n\n    Monkey-patches :envvar:`NETRC` to point to created file.\n    \"\"\"\n    netrc_contents = getattr(request, \"param\", None)\n\n    netrc_file_path = tmp_path / \".netrc\"\n    if netrc_contents is not None:\n        netrc_file_path.write_text(netrc_contents)\n\n    monkeypatch.setenv(\"NETRC\", str(netrc_file_path))\n\n    return netrc_file_path\n\n\n@pytest.fixture\ndef start_connection():\n    with mock.patch(\n        \"aiohttp.connector.aiohappyeyeballs.start_connection\",\n        autospec=True,\n        spec_set=True,\n    ) as start_connection_mock:\n        yield start_connection_mock\n\n\n@pytest.fixture\ndef key_data():\n    return os.urandom(16)\n\n\n@pytest.fixture\ndef key(key_data: Any):\n    return base64.b64encode(key_data)\n\n\n@pytest.fixture\ndef ws_key(key: Any):\n    return base64.b64encode(sha1(key + WS_KEY).digest()).decode()\n"
    ],
    "test_file_names": [
        "test_1.py",
        "conftest.py"
    ],
    "setup_res_code": 0,
    "setup_res_stdout": "re-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/requirements/cython.txt\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/tools/gen.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/hdrs.py\n./tools/gen.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/_helpers.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/_http_parser.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/_http_writer.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/_websocket.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/_helpers.pyi\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/_cparser.pxd\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/_find_header.pxd\ncython -3 -o aiohttp/_helpers.c aiohttp/_helpers.pyx -I aiohttp -Werror\ncython -3 -o aiohttp/_http_parser.c aiohttp/_http_parser.pyx -I aiohttp -Werror\ncython -3 -o aiohttp/_http_writer.c aiohttp/_http_writer.pyx -I aiohttp -Werror\ncython -3 -o aiohttp/_websocket.c aiohttp/_websocket.pyx -I aiohttp -Werror\ncd vendor/llhttp; npm ci\n\n> llhttp@9.2.1 prepare\n> npm run clean && npm run build-ts\n\n\n> llhttp@9.2.1 clean\n> rm -rf lib && rm -rf test/tmp\n\n\n> llhttp@9.2.1 build-ts\n> tsc\n\n\nadded 213 packages, and audited 214 packages in 5s\n\n41 packages are looking for funding\n  run `npm fund` for details\n\n5 vulnerabilities (3 moderate, 2 high)\n\nTo address issues that do not require attention, run:\n  npm audit fix\n\nSome issues need review, and may require choosing\na different dependency.\n\nRun `npm audit` for details.\nmake -C vendor/llhttp generate\nmake[1]: Entering directory '/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/vendor/llhttp'\nnpx ts-node bin/generate.ts\nmake[1]: Leaving directory '/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/vendor/llhttp'\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/__init__.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/abc.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/base_protocol.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/client.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/client_exceptions.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/client_proto.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/client_reqrep.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/client_ws.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/compression_utils.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/connector.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/cookiejar.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/formdata.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/helpers.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/http.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/http_exceptions.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/http_parser.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/http_websocket.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/http_writer.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/locks.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/log.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/multipart.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/payload.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/payload_streamer.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/pytest_plugin.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/resolver.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/streams.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/tcp_helpers.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/test_utils.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/tracing.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/typedefs.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/web.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/web_app.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/web_exceptions.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/web_fileresponse.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/web_log.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/web_middlewares.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/web_protocol.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/web_request.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/web_response.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/web_routedef.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/web_runner.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/web_server.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/web_urldispatcher.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/web_ws.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/aiohttp/worker.py\nuv pip install -e . -c requirements/runtime-deps.txt\n",
    "setup_res_stderr": "Using CPython 3.9.21\nCreating virtual environment at: .venv\nActivate with: source .venv/bin/activate\nResolved 1 package in 2ms\nPrepared 1 package in 0.27ms\nInstalled 1 package in 16ms\n + pip==24.3.1\nResolved 2 packages in 11ms\nInstalled 2 packages in 42ms\n + cython==3.0.10\n + multidict==6.0.5\nResolved 96 packages in 51ms\nUninstalled 1 package in 44ms\nInstalled 95 packages in 210ms\n + aiodns==3.2.0\n + aiohappyeyeballs==2.3.4\n + aiohttp-theme==0.1.7\n + aioredis==2.0.1\n + aiosignal==1.3.1\n + alabaster==0.7.13\n + annotated-types==0.7.0\n + async-timeout==4.0.3\n + attrs==23.2.0\n + babel==2.12.1\n + blockdiag==3.0.0\n + brotli==1.1.0\n + build==1.0.3\n + certifi==2023.7.22\n + cffi==1.17.0\n + cfgv==3.3.1\n + charset-normalizer==3.2.0\n + cherry-picker==2.2.0\n + click==8.1.6\n + coverage==7.6.0\n + cryptography==41.0.3\n + distlib==0.3.7\n + docutils==0.20.1\n + exceptiongroup==1.1.2\n + filelock==3.12.2\n + freezegun==1.5.1\n + frozenlist==1.4.1\n + funcparserlib==1.0.1\n + gidgethub==5.3.0\n + gunicorn==22.0.0\n + identify==2.5.26\n + idna==3.4\n + imagesize==1.4.1\n + importlib-metadata==7.0.0\n + importlib-resources==6.1.1\n + incremental==22.10.0\n + iniconfig==2.0.0\n + jinja2==3.1.2\n + markupsafe==2.1.3\n + mypy==1.11.1\n + mypy-extensions==1.0.0\n + nodeenv==1.8.0\n + packaging==23.1\n + pillow==9.5.0\n - pip==24.3.1\n + pip==23.2.1\n + pip-tools==7.4.1\n + platformdirs==3.10.0\n + pluggy==1.5.0\n + pre-commit==3.5.0\n + proxy-py==2.4.4\n + pycares==4.3.0\n + pycparser==2.21\n + pydantic==2.9.2\n + pydantic-core==2.23.4\n + pygments==2.15.1\n + pyjwt==2.8.0\n + pyproject-hooks==1.0.0\n + pytest==8.3.2\n + pytest-cov==5.0.0\n + pytest-mock==3.14.0\n + python-dateutil==2.8.2\n + python-on-whales==0.72.0\n + pyyaml==6.0.1\n + re-assert==1.1.0\n + regex==2024.9.11\n + requests==2.31.0\n + setuptools==68.0.0\n + setuptools-git==1.2\n + six==1.16.0\n + slotscheck==0.19.0\n + snowballstemmer==2.2.0\n + sphinx==7.1.2\n + sphinxcontrib-applehelp==1.0.4\n + sphinxcontrib-blockdiag==3.0.0\n + sphinxcontrib-devhelp==1.0.2\n + sphinxcontrib-htmlhelp==2.0.1\n + sphinxcontrib-jsmath==1.0.1\n + sphinxcontrib-qthelp==1.0.3\n + sphinxcontrib-serializinghtml==1.1.5\n + sphinxcontrib-towncrier==0.4.0a0\n + tomli==2.0.1\n + towncrier==23.11.0\n + tqdm==4.65.0\n + trustme==1.1.0\n + typer==0.9.0\n + typing-extensions==4.12.2\n + uritemplate==4.1.1\n + urllib3==2.0.4\n + uvloop==0.21.0b1\n + virtualenv==20.24.2\n + wait-for-it==2.2.2\n + webcolors==1.13\n + wheel==0.41.0\n + yarl==1.13.0\n + zipp==3.17.0\nResolved 9 packages in 1.69s\nPrepared 1 package in 16.76s\nInstalled 1 package in 0.57ms\n + aiohttp==3.10.10.dev0 (from file:///home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c)\nResolved 24 packages in 15ms\nInstalled 5 packages in 5ms\n + async-generator==1.10\n + brotlipy==0.7.0\n + chardet==5.2.0\n + multdict==0.0.5\n + pytest-asyncio==0.25.1\n",
    "new_commit_res_code": 0,
    "new_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.9.21, pytest-8.3.2, pluggy-1.5.0 -- /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/.venv/bin/python\ncachedir: .pytest_cache\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c\nconfigfile: setup.cfg\nplugins: cov-5.0.0, mock-3.14.0, asyncio-0.25.1\nasyncio: mode=strict, asyncio_default_fixture_loop_scope=None\ncollecting ... collected 24 items\n\nr2e_tests/test_1.py::test_async_resolver_positive_ipv4_lookup[pyloop] PASSED [  4%]\nr2e_tests/test_1.py::test_async_resolver_positive_link_local_ipv6_lookup[pyloop] PASSED [  8%]\nr2e_tests/test_1.py::test_async_resolver_multiple_replies[pyloop] PASSED [ 12%]\nr2e_tests/test_1.py::test_async_resolver_query_multiple_replies[pyloop] PASSED [ 16%]\nr2e_tests/test_1.py::test_async_resolver_negative_lookup[pyloop] PASSED  [ 20%]\nr2e_tests/test_1.py::test_async_resolver_no_hosts_in_getaddrinfo[pyloop] PASSED [ 25%]\nr2e_tests/test_1.py::test_threaded_resolver_positive_lookup PASSED       [ 29%]\nr2e_tests/test_1.py::test_threaded_resolver_positive_ipv6_link_local_lookup PASSED [ 33%]\nr2e_tests/test_1.py::test_threaded_resolver_multiple_replies PASSED      [ 37%]\nr2e_tests/test_1.py::test_threaded_negative_lookup PASSED                [ 41%]\nr2e_tests/test_1.py::test_threaded_negative_ipv6_lookup PASSED           [ 45%]\nr2e_tests/test_1.py::test_threaded_negative_lookup_with_unknown_result PASSED [ 50%]\nr2e_tests/test_1.py::test_close_for_threaded_resolver[pyloop] PASSED     [ 54%]\nr2e_tests/test_1.py::test_close_for_async_resolver[pyloop] PASSED        [ 58%]\nr2e_tests/test_1.py::test_default_loop_for_threaded_resolver[pyloop] PASSED [ 62%]\nr2e_tests/test_1.py::test_async_resolver_ipv6_positive_lookup[pyloop] PASSED [ 66%]\nr2e_tests/test_1.py::test_async_resolver_query_ipv6_positive_lookup[pyloop] PASSED [ 70%]\nr2e_tests/test_1.py::test_async_resolver_query_fallback_error_messages_passed[pyloop] PASSED [ 75%]\nr2e_tests/test_1.py::test_async_resolver_query_fallback_error_messages_passed_no_hosts[pyloop] PASSED [ 79%]\nr2e_tests/test_1.py::test_async_resolver_error_messages_passed[pyloop] PASSED [ 83%]\nr2e_tests/test_1.py::test_async_resolver_error_messages_passed_no_hosts[pyloop] PASSED [ 87%]\nr2e_tests/test_1.py::test_async_resolver_aiodns_not_present[pyloop] PASSED [ 91%]\nr2e_tests/test_1.py::test_aio_dns_is_default PASSED                      [ 95%]\nr2e_tests/test_1.py::test_threaded_resolver_is_default SKIPPED (aiod...) [100%]\n\n==================================== PASSES ====================================\n\n---------- coverage: platform linux, python 3.9.21-final-0 -----------\nName                                     Stmts   Miss Branch BrPart  Cover\n--------------------------------------------------------------------------\naiohttp/__init__.py                         27     10      2      0    59%\naiohttp/abc.py                              97      8      0      0    92%\naiohttp/base_protocol.py                    68     51     22      0    19%\naiohttp/client.py                          541    393    196      3    21%\naiohttp/client_exceptions.py               154     69     20      0    49%\naiohttp/client_proto.py                    166    132     56      0    15%\naiohttp/client_reqrep.py                   717    541    312      0    18%\naiohttp/client_ws.py                       264    214     80      1    15%\naiohttp/compression_utils.py                70     36     14      0    40%\naiohttp/connector.py                       765    616    327      1    14%\naiohttp/cookiejar.py                       274    217    130      0    14%\naiohttp/formdata.py                         97     79     46      0    13%\naiohttp/hdrs.py                             90      0      0      0   100%\naiohttp/helpers.py                         511    337    182      2    27%\naiohttp/http.py                             11      0      2      0   100%\naiohttp/http_exceptions.py                  50     20      4      0    56%\naiohttp/http_parser.py                     508    408    210      1    14%\naiohttp/http_websocket.py                  394    287    152      0    20%\naiohttp/http_writer.py                     119     81     50      1    23%\naiohttp/locks.py                            24     16      4      0    29%\naiohttp/log.py                               7      0      0      0   100%\naiohttp/multipart.py                       623    508    266      1    13%\naiohttp/payload.py                         237    113     58      1    44%\naiohttp/payload_streamer.py                 31     11      4      0    69%\naiohttp/pytest_plugin.py                   163     77     42      4    51%\naiohttp/resolver.py                         81      1     26      1    98%\naiohttp/streams.py                         398    315    146      0    15%\naiohttp/tcp_helpers.py                      19     11      6      0    32%\naiohttp/test_utils.py                      318    197     52      3    34%\naiohttp/tracing.py                         191     69     32      0    69%\naiohttp/typedefs.py                         24      0      0      0   100%\naiohttp/web.py                             122     84     52      0    23%\naiohttp/web_app.py                         292    196     82      0    26%\naiohttp/web_exceptions.py                  157     25      8      0    80%\naiohttp/web_fileresponse.py                163    127     54      1    19%\naiohttp/web_log.py                         102     58     20      0    36%\naiohttp/web_middlewares.py                  59     46     22      0    16%\naiohttp/web_protocol.py                    367    306    158      0    12%\naiohttp/web_request.py                     445    294    140      1    27%\naiohttp/web_response.py                    482    365    226      0    17%\naiohttp/web_routedef.py                    100     44     10      0    55%\naiohttp/web_runner.py                      213    130     36      0    33%\naiohttp/web_server.py                       42     24     12      0    33%\naiohttp/web_urldispatcher.py               740    474    163      0    29%\naiohttp/web_ws.py                          382    310    132      1    15%\naiohttp/worker.py                          126    126     30      0     0%\ntests/conftest.py                          131    131     16      0     0%\ntests/test_base_protocol.py                198    198      2      0     0%\ntests/test_circular_imports.py              29     29     13      0     0%\ntests/test_classbasedview.py                39     39      0      0     0%\ntests/test_client_connection.py             94     94      2      0     0%\ntests/test_client_exceptions.py            199    199     14      0     0%\ntests/test_client_fingerprint.py            59     59      0      0     0%\ntests/test_client_functional.py           2523   2523     86      0     0%\ntests/test_client_proto.py                  99     99      0      0     0%\ntests/test_client_request.py               829    829     18      0     0%\ntests/test_client_response.py              480    480      6      0     0%\ntests/test_client_session.py               566    566     29      0     0%\ntests/test_client_ws.py                    486    486      2      0     0%\ntests/test_client_ws_functional.py         750    750     32      0     0%\ntests/test_connector.py                   1744   1744     92      0     0%\ntests/test_cookiejar.py                    461    461     32      0     0%\ntests/test_flowcontrol_streams.py          100    100      0      0     0%\ntests/test_formdata.py                      81     81      6      0     0%\ntests/test_helpers.py                      509    509     24      0     0%\ntests/test_http_exceptions.py              109    109     10      0     0%\ntests/test_http_parser.py                 1092   1092     66      0     0%\ntests/test_http_writer.py                  182    182     10      0     0%\ntests/test_imports.py                       34     34      6      0     0%\ntests/test_locks.py                         39     39      0      0     0%\ntests/test_loop.py                          36     36      0      0     0%\ntests/test_multipart.py                    826    826     32      0     0%\ntests/test_multipart_helpers.py            446    446      0      0     0%\ntests/test_payload.py                       95     95      0      0     0%\ntests/test_proxy.py                        302    302      0      0     0%\ntests/test_proxy_functional.py             461    461     18      0     0%\ntests/test_pytest_plugin.py                 27     27      0      0     0%\ntests/test_resolver.py                     233    233     20      0     0%\ntests/test_route_def.py                    210    210      0      0     0%\ntests/test_run_app.py                      563    563     30      0     0%\ntests/test_streams.py                     1077   1077     38      0     0%\ntests/test_tcp_helpers.py                   52     52      2      0     0%\ntests/test_test_utils.py                   251    251      6      0     0%\ntests/test_tracing.py                       48     48      0      0     0%\ntests/test_urldispatch.py                  859    859     24      0     0%\ntests/test_web_app.py                      454    454      6      0     0%\ntests/test_web_cli.py                       75     75      0      0     0%\ntests/test_web_exceptions.py               179    179     22      0     0%\ntests/test_web_functional.py              1605   1605     36      0     0%\ntests/test_web_log.py                      116    116      2      0     0%\ntests/test_web_middleware.py               268    268     16      0     0%\ntests/test_web_request.py                  513    513      8      0     0%\ntests/test_web_request_handler.py           42     42      0      0     0%\ntests/test_web_response.py                 904    904      6      0     0%\ntests/test_web_runner.py                   151    151      4      0     0%\ntests/test_web_sendfile.py                  84     84      0      0     0%\ntests/test_web_sendfile_functional.py      673    673     18      0     0%\ntests/test_web_server.py                   162    162      0      0     0%\ntests/test_web_urldispatcher.py            524    524     24      0     0%\ntests/test_web_websocket.py                401    401      8      0     0%\ntests/test_web_websocket_functional.py     799    799     28      0     0%\ntests/test_websocket_handshake.py          152    152     12      0     0%\ntests/test_websocket_parser.py             300    300     12      0     0%\ntests/test_websocket_writer.py              95     95      6      0     0%\ntests/test_worker.py                       191    191      2      0     0%\n--------------------------------------------------------------------------\nTOTAL                                    34838  31433   4432     22     9%\n\n============================= slowest 10 durations =============================\n0.03s call     r2e_tests/test_1.py::test_threaded_resolver_positive_ipv6_link_local_lookup\n0.02s teardown r2e_tests/test_1.py::test_async_resolver_positive_ipv4_lookup[pyloop]\n0.02s teardown r2e_tests/test_1.py::test_async_resolver_query_fallback_error_messages_passed[pyloop]\n0.01s teardown r2e_tests/test_1.py::test_async_resolver_query_fallback_error_messages_passed_no_hosts[pyloop]\n0.01s teardown r2e_tests/test_1.py::test_async_resolver_error_messages_passed[pyloop]\n0.01s teardown r2e_tests/test_1.py::test_async_resolver_error_messages_passed_no_hosts[pyloop]\n0.01s teardown r2e_tests/test_1.py::test_async_resolver_query_multiple_replies[pyloop]\n0.01s teardown r2e_tests/test_1.py::test_async_resolver_multiple_replies[pyloop]\n0.01s teardown r2e_tests/test_1.py::test_async_resolver_negative_lookup[pyloop]\n0.01s teardown r2e_tests/test_1.py::test_async_resolver_positive_link_local_ipv6_lookup[pyloop]\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::test_async_resolver_positive_ipv4_lookup[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_positive_link_local_ipv6_lookup[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_multiple_replies[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_query_multiple_replies[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_negative_lookup[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_no_hosts_in_getaddrinfo[pyloop]\nPASSED r2e_tests/test_1.py::test_threaded_resolver_positive_lookup\nPASSED r2e_tests/test_1.py::test_threaded_resolver_positive_ipv6_link_local_lookup\nPASSED r2e_tests/test_1.py::test_threaded_resolver_multiple_replies\nPASSED r2e_tests/test_1.py::test_threaded_negative_lookup\nPASSED r2e_tests/test_1.py::test_threaded_negative_ipv6_lookup\nPASSED r2e_tests/test_1.py::test_threaded_negative_lookup_with_unknown_result\nPASSED r2e_tests/test_1.py::test_close_for_threaded_resolver[pyloop]\nPASSED r2e_tests/test_1.py::test_close_for_async_resolver[pyloop]\nPASSED r2e_tests/test_1.py::test_default_loop_for_threaded_resolver[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_ipv6_positive_lookup[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_query_ipv6_positive_lookup[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_query_fallback_error_messages_passed[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_query_fallback_error_messages_passed_no_hosts[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_error_messages_passed[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_error_messages_passed_no_hosts[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_aiodns_not_present[pyloop]\nPASSED r2e_tests/test_1.py::test_aio_dns_is_default\nSKIPPED [1] r2e_tests/test_1.py:411: aiodns <3.2.0 required\n======================== 23 passed, 1 skipped in 4.60s =========================\n",
    "new_commit_res_stderr": "/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/.venv/lib/python3.9/site-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option \"asyncio_default_fixture_loop_scope\" is unset.\nThe event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: \"function\", \"class\", \"module\", \"package\", \"session\"\n\n  warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))\n",
    "old_commit_res_code": 1,
    "old_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.9.21, pytest-8.3.2, pluggy-1.5.0 -- /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/.venv/bin/python\ncachedir: .pytest_cache\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c\nconfigfile: setup.cfg\nplugins: cov-5.0.0, mock-3.14.0, asyncio-0.25.1\nasyncio: mode=strict, asyncio_default_fixture_loop_scope=None\ncollecting ... collected 24 items\n\nr2e_tests/test_1.py::test_async_resolver_positive_ipv4_lookup[pyloop] PASSED [  4%]\nr2e_tests/test_1.py::test_async_resolver_positive_link_local_ipv6_lookup[pyloop] PASSED [  8%]\nr2e_tests/test_1.py::test_async_resolver_multiple_replies[pyloop] PASSED [ 12%]\nr2e_tests/test_1.py::test_async_resolver_query_multiple_replies[pyloop] PASSED [ 16%]\nr2e_tests/test_1.py::test_async_resolver_negative_lookup[pyloop] PASSED  [ 20%]\nr2e_tests/test_1.py::test_async_resolver_no_hosts_in_getaddrinfo[pyloop] PASSED [ 25%]\nr2e_tests/test_1.py::test_threaded_resolver_positive_lookup PASSED       [ 29%]\nr2e_tests/test_1.py::test_threaded_resolver_positive_ipv6_link_local_lookup PASSED [ 33%]\nr2e_tests/test_1.py::test_threaded_resolver_multiple_replies PASSED      [ 37%]\nr2e_tests/test_1.py::test_threaded_negative_lookup PASSED                [ 41%]\nr2e_tests/test_1.py::test_threaded_negative_ipv6_lookup PASSED           [ 45%]\nr2e_tests/test_1.py::test_threaded_negative_lookup_with_unknown_result PASSED [ 50%]\nr2e_tests/test_1.py::test_close_for_threaded_resolver[pyloop] PASSED     [ 54%]\nr2e_tests/test_1.py::test_close_for_async_resolver[pyloop] PASSED        [ 58%]\nr2e_tests/test_1.py::test_default_loop_for_threaded_resolver[pyloop] PASSED [ 62%]\nr2e_tests/test_1.py::test_async_resolver_ipv6_positive_lookup[pyloop] PASSED [ 66%]\nr2e_tests/test_1.py::test_async_resolver_query_ipv6_positive_lookup[pyloop] PASSED [ 70%]\nr2e_tests/test_1.py::test_async_resolver_query_fallback_error_messages_passed[pyloop] FAILED [ 75%]\nr2e_tests/test_1.py::test_async_resolver_query_fallback_error_messages_passed_no_hosts[pyloop] FAILED [ 79%]\nr2e_tests/test_1.py::test_async_resolver_error_messages_passed[pyloop] PASSED [ 83%]\nr2e_tests/test_1.py::test_async_resolver_error_messages_passed_no_hosts[pyloop] PASSED [ 87%]\nr2e_tests/test_1.py::test_async_resolver_aiodns_not_present[pyloop] PASSED [ 91%]\nr2e_tests/test_1.py::test_aio_dns_is_default PASSED                      [ 95%]\nr2e_tests/test_1.py::test_threaded_resolver_is_default SKIPPED (aiod...) [100%]\n\n=================================== FAILURES ===================================\n_______ test_async_resolver_query_fallback_error_messages_passed[pyloop] _______\n\nloop = <_UnixSelectorEventLoop running=False closed=False debug=False>\n\n    @pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\n    async def test_async_resolver_query_fallback_error_messages_passed(\n        loop: asyncio.AbstractEventLoop,\n    ) -> None:\n        \"\"\"Ensure error messages are passed through from aiodns with query fallback.\"\"\"\n        with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:\n            del mock().gethostbyname\n            mock().query.side_effect = aiodns.error.DNSError(1, \"Test error message\")\n            resolver = AsyncResolver()\n            with pytest.raises(OSError, match=\"Test error message\") as excinfo:\n                await resolver.resolve(\"x.org\")\n    \n>           assert excinfo.value.strerror == \"Test error message\"\nE           AssertionError: assert None == 'Test error message'\nE            +  where None = OSError('Test error message').strerror\nE            +    where OSError('Test error message') = <ExceptionInfo OSError('Test error message') tblen=2>.value\n\nexcinfo    = <ExceptionInfo OSError('Test error message') tblen=2>\nloop       = <_UnixSelectorEventLoop running=False closed=False debug=False>\nmock       = <MagicMock name='DNSResolver' spec_set='DNSResolver' id='138734818869456'>\nresolver   = <aiohttp.resolver.AsyncResolver object at 0x7e2db791b550>\n\nr2e_tests/test_1.py:354: AssertionError\n__ test_async_resolver_query_fallback_error_messages_passed_no_hosts[pyloop] ___\n\nloop = <_UnixSelectorEventLoop running=False closed=False debug=False>\n\n    @pytest.mark.skipif(not getaddrinfo, reason=\"aiodns >=3.2.0 required\")\n    async def test_async_resolver_query_fallback_error_messages_passed_no_hosts(\n        loop: asyncio.AbstractEventLoop,\n    ) -> None:\n        \"\"\"Ensure error messages are passed through from aiodns with query fallback.\"\"\"\n        with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:\n            del mock().gethostbyname\n            mock().query.return_value = fake_query_result([])\n            resolver = AsyncResolver()\n            with pytest.raises(OSError, match=\"DNS lookup failed\") as excinfo:\n                await resolver.resolve(\"x.org\")\n    \n>           assert excinfo.value.strerror == \"DNS lookup failed\"\nE           AssertionError: assert None == 'DNS lookup failed'\nE            +  where None = OSError('DNS lookup failed').strerror\nE            +    where OSError('DNS lookup failed') = <ExceptionInfo OSError('DNS lookup failed') tblen=2>.value\n\nexcinfo    = <ExceptionInfo OSError('DNS lookup failed') tblen=2>\nloop       = <_UnixSelectorEventLoop running=False closed=False debug=False>\nmock       = <MagicMock name='DNSResolver' spec_set='DNSResolver' id='138734818118624'>\nresolver   = <aiohttp.resolver.AsyncResolver object at 0x7e2db78db610>\n\nr2e_tests/test_1.py:369: AssertionError\n==================================== PASSES ====================================\n\n---------- coverage: platform linux, python 3.9.21-final-0 -----------\nName                                     Stmts   Miss Branch BrPart  Cover\n--------------------------------------------------------------------------\naiohttp/__init__.py                         27     10      2      0    59%\naiohttp/abc.py                              97      8      0      0    92%\naiohttp/base_protocol.py                    68     51     22      0    19%\naiohttp/client.py                          541    393    196      3    21%\naiohttp/client_exceptions.py               154     69     20      0    49%\naiohttp/client_proto.py                    166    132     56      0    15%\naiohttp/client_reqrep.py                   717    541    312      0    18%\naiohttp/client_ws.py                       264    214     80      1    15%\naiohttp/compression_utils.py                70     36     14      0    40%\naiohttp/connector.py                       765    616    327      1    14%\naiohttp/cookiejar.py                       274    217    130      0    14%\naiohttp/formdata.py                         97     79     46      0    13%\naiohttp/hdrs.py                             90      0      0      0   100%\naiohttp/helpers.py                         511    337    182      2    27%\naiohttp/http.py                             11      0      2      0   100%\naiohttp/http_exceptions.py                  50     20      4      0    56%\naiohttp/http_parser.py                     508    408    210      1    14%\naiohttp/http_websocket.py                  394    287    152      0    20%\naiohttp/http_writer.py                     119     81     50      1    23%\naiohttp/locks.py                            24     16      4      0    29%\naiohttp/log.py                               7      0      0      0   100%\naiohttp/multipart.py                       623    508    266      1    13%\naiohttp/payload.py                         237    113     58      1    44%\naiohttp/payload_streamer.py                 31     11      4      0    69%\naiohttp/pytest_plugin.py                   163     76     42      4    51%\naiohttp/resolver.py                         81      1     26      1    98%\naiohttp/streams.py                         398    315    146      0    15%\naiohttp/tcp_helpers.py                      19     11      6      0    32%\naiohttp/test_utils.py                      318    197     52      3    34%\naiohttp/tracing.py                         191     69     32      0    69%\naiohttp/typedefs.py                         24      0      0      0   100%\naiohttp/web.py                             122     84     52      0    23%\naiohttp/web_app.py                         292    196     82      0    26%\naiohttp/web_exceptions.py                  157     25      8      0    80%\naiohttp/web_fileresponse.py                163    127     54      1    19%\naiohttp/web_log.py                         102     58     20      0    36%\naiohttp/web_middlewares.py                  59     46     22      0    16%\naiohttp/web_protocol.py                    367    306    158      0    12%\naiohttp/web_request.py                     445    294    140      1    27%\naiohttp/web_response.py                    482    365    226      0    17%\naiohttp/web_routedef.py                    100     44     10      0    55%\naiohttp/web_runner.py                      213    130     36      0    33%\naiohttp/web_server.py                       42     24     12      0    33%\naiohttp/web_urldispatcher.py               740    474    163      0    29%\naiohttp/web_ws.py                          382    310    132      1    15%\naiohttp/worker.py                          126    126     30      0     0%\ntests/conftest.py                          131    131     16      0     0%\ntests/test_base_protocol.py                198    198      2      0     0%\ntests/test_circular_imports.py              29     29     13      0     0%\ntests/test_classbasedview.py                39     39      0      0     0%\ntests/test_client_connection.py             94     94      2      0     0%\ntests/test_client_exceptions.py            199    199     14      0     0%\ntests/test_client_fingerprint.py            59     59      0      0     0%\ntests/test_client_functional.py           2523   2523     86      0     0%\ntests/test_client_proto.py                  99     99      0      0     0%\ntests/test_client_request.py               829    829     18      0     0%\ntests/test_client_response.py              480    480      6      0     0%\ntests/test_client_session.py               566    566     29      0     0%\ntests/test_client_ws.py                    486    486      2      0     0%\ntests/test_client_ws_functional.py         750    750     32      0     0%\ntests/test_connector.py                   1744   1744     92      0     0%\ntests/test_cookiejar.py                    461    461     32      0     0%\ntests/test_flowcontrol_streams.py          100    100      0      0     0%\ntests/test_formdata.py                      81     81      6      0     0%\ntests/test_helpers.py                      509    509     24      0     0%\ntests/test_http_exceptions.py              109    109     10      0     0%\ntests/test_http_parser.py                 1092   1092     66      0     0%\ntests/test_http_writer.py                  182    182     10      0     0%\ntests/test_imports.py                       34     34      6      0     0%\ntests/test_locks.py                         39     39      0      0     0%\ntests/test_loop.py                          36     36      0      0     0%\ntests/test_multipart.py                    826    826     32      0     0%\ntests/test_multipart_helpers.py            446    446      0      0     0%\ntests/test_payload.py                       95     95      0      0     0%\ntests/test_proxy.py                        302    302      0      0     0%\ntests/test_proxy_functional.py             461    461     18      0     0%\ntests/test_pytest_plugin.py                 27     27      0      0     0%\ntests/test_resolver.py                     215    215     20      0     0%\ntests/test_route_def.py                    210    210      0      0     0%\ntests/test_run_app.py                      563    563     30      0     0%\ntests/test_streams.py                     1077   1077     38      0     0%\ntests/test_tcp_helpers.py                   52     52      2      0     0%\ntests/test_test_utils.py                   251    251      6      0     0%\ntests/test_tracing.py                       48     48      0      0     0%\ntests/test_urldispatch.py                  859    859     24      0     0%\ntests/test_web_app.py                      454    454      6      0     0%\ntests/test_web_cli.py                       75     75      0      0     0%\ntests/test_web_exceptions.py               179    179     22      0     0%\ntests/test_web_functional.py              1605   1605     36      0     0%\ntests/test_web_log.py                      116    116      2      0     0%\ntests/test_web_middleware.py               268    268     16      0     0%\ntests/test_web_request.py                  513    513      8      0     0%\ntests/test_web_request_handler.py           42     42      0      0     0%\ntests/test_web_response.py                 904    904      6      0     0%\ntests/test_web_runner.py                   151    151      4      0     0%\ntests/test_web_sendfile.py                  84     84      0      0     0%\ntests/test_web_sendfile_functional.py      673    673     18      0     0%\ntests/test_web_server.py                   162    162      0      0     0%\ntests/test_web_urldispatcher.py            524    524     24      0     0%\ntests/test_web_websocket.py                401    401      8      0     0%\ntests/test_web_websocket_functional.py     799    799     28      0     0%\ntests/test_websocket_handshake.py          152    152     12      0     0%\ntests/test_websocket_parser.py             300    300     12      0     0%\ntests/test_websocket_writer.py              95     95      6      0     0%\ntests/test_worker.py                       191    191      2      0     0%\n--------------------------------------------------------------------------\nTOTAL                                    34820  31414   4432     22     9%\n\n============================= slowest 10 durations =============================\n0.05s call     r2e_tests/test_1.py::test_threaded_resolver_positive_ipv6_link_local_lookup\n0.03s teardown r2e_tests/test_1.py::test_async_resolver_error_messages_passed[pyloop]\n0.03s teardown r2e_tests/test_1.py::test_async_resolver_query_fallback_error_messages_passed[pyloop]\n0.03s teardown r2e_tests/test_1.py::test_async_resolver_no_hosts_in_getaddrinfo[pyloop]\n0.03s teardown r2e_tests/test_1.py::test_async_resolver_query_fallback_error_messages_passed_no_hosts[pyloop]\n0.03s teardown r2e_tests/test_1.py::test_async_resolver_query_ipv6_positive_lookup[pyloop]\n0.02s teardown r2e_tests/test_1.py::test_default_loop_for_threaded_resolver[pyloop]\n0.02s call     r2e_tests/test_1.py::test_async_resolver_query_fallback_error_messages_passed[pyloop]\n0.02s call     r2e_tests/test_1.py::test_async_resolver_error_messages_passed_no_hosts[pyloop]\n0.02s call     r2e_tests/test_1.py::test_threaded_resolver_positive_lookup\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::test_async_resolver_positive_ipv4_lookup[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_positive_link_local_ipv6_lookup[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_multiple_replies[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_query_multiple_replies[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_negative_lookup[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_no_hosts_in_getaddrinfo[pyloop]\nPASSED r2e_tests/test_1.py::test_threaded_resolver_positive_lookup\nPASSED r2e_tests/test_1.py::test_threaded_resolver_positive_ipv6_link_local_lookup\nPASSED r2e_tests/test_1.py::test_threaded_resolver_multiple_replies\nPASSED r2e_tests/test_1.py::test_threaded_negative_lookup\nPASSED r2e_tests/test_1.py::test_threaded_negative_ipv6_lookup\nPASSED r2e_tests/test_1.py::test_threaded_negative_lookup_with_unknown_result\nPASSED r2e_tests/test_1.py::test_close_for_threaded_resolver[pyloop]\nPASSED r2e_tests/test_1.py::test_close_for_async_resolver[pyloop]\nPASSED r2e_tests/test_1.py::test_default_loop_for_threaded_resolver[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_ipv6_positive_lookup[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_query_ipv6_positive_lookup[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_error_messages_passed[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_error_messages_passed_no_hosts[pyloop]\nPASSED r2e_tests/test_1.py::test_async_resolver_aiodns_not_present[pyloop]\nPASSED r2e_tests/test_1.py::test_aio_dns_is_default\nSKIPPED [1] r2e_tests/test_1.py:411: aiodns <3.2.0 required\nFAILED r2e_tests/test_1.py::test_async_resolver_query_fallback_error_messages_passed[pyloop]\nFAILED r2e_tests/test_1.py::test_async_resolver_query_fallback_error_messages_passed_no_hosts[pyloop]\n=================== 2 failed, 21 passed, 1 skipped in 5.34s ====================\n",
    "old_commit_res_stderr": "/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_ee87a049be63887c0a5d9f4e6008b4e47460f16c/.venv/lib/python3.9/site-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option \"asyncio_default_fixture_loop_scope\" is unset.\nThe event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: \"function\", \"class\", \"module\", \"package\", \"session\"\n\n  warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))\n"
}
CHANGES/9455.bugfix.rst aiohttp/resolver.py tests/test_resolver.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** AsyncResolver Fallback Suppresses DNS Error Messages

**Description:**
When a DNS query fallback occurs in `AsyncResolver`, the raised `OSError` does not include the original error message. This makes it difficult to understand the reason behind the DNS lookup failure.

**Example Code:**
```python
import asyncio
from aiohttp.resolver import AsyncResolver

async def resolve_host():
    resolver = AsyncResolver()
    try:
        await resolver.resolve("invalid.host")
    except OSError as e:
        print(f"Error message: {e.strerror}")

asyncio.run(resolve_host())
```

**Expected Behavior:**
When resolving an invalid hostname, the `OSError` should contain the specific error message from the DNS resolver, allowing developers to see details about why the DNS lookup failed.

**Actual Behavior:**
The `OSError` is raised with `strerror` set to `None`, resulting in no error message being displayed:
```
Error message: None
```
[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### aiohttp/resolver.py
import asyncio
import socket
import sys
from typing import Any, Dict, List, Optional, Tuple, Type, Union

from .abc import AbstractResolver, ResolveResult

__all__ = ("ThreadedResolver", "AsyncResolver", "DefaultResolver")


try:
    import aiodns

    aiodns_default = hasattr(aiodns.DNSResolver, "getaddrinfo")
except ImportError:  # pragma: no cover
    aiodns = None  # type: ignore[assignment]
    aiodns_default = False


_NUMERIC_SOCKET_FLAGS = socket.AI_NUMERICHOST | socket.AI_NUMERICSERV
_NAME_SOCKET_FLAGS = socket.NI_NUMERICHOST | socket.NI_NUMERICSERV
_SUPPORTS_SCOPE_ID = sys.version_info >= (3, 9, 0)


class ThreadedResolver(AbstractResolver):
    """Threaded resolver.

    Uses an Executor for synchronous getaddrinfo() calls.
    concurrent.futures.ThreadPoolExecutor is used by default.
    """

    def __init__(self, loop: Optional[asyncio.AbstractEventLoop] = None) -> None:
        self._loop = loop or asyncio.get_running_loop()

    async def resolve(
        self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET
    ) -> List[ResolveResult]:
        infos = await self._loop.getaddrinfo(
            host,
            port,
            type=socket.SOCK_STREAM,
            family=family,
            flags=socket.AI_ADDRCONFIG,
        )

        hosts: List[ResolveResult] = []
        for family, _, proto, _, address in infos:
            if family == socket.AF_INET6:
                if len(address) < 3:
                    # IPv6 is not supported by Python build,
                    # or IPv6 is not enabled in the host
                    continue
                if address[3] and _SUPPORTS_SCOPE_ID:
                    # This is essential for link-local IPv6 addresses.
                    # LL IPv6 is a VERY rare case. Strictly speaking, we should use
                    # getnameinfo() unconditionally, but performance makes sense.
                    resolved_host, _port = await self._loop.getnameinfo(
                        address, _NAME_SOCKET_FLAGS
                    )
                    port = int(_port)
                else:
                    resolved_host, port = address[:2]
            else:  # IPv4
                assert family == socket.AF_INET
                resolved_host, port = address  # type: ignore[misc]
            hosts.append(
                ResolveResult(
                    hostname=host,
                    host=resolved_host,
                    port=port,
                    family=family,
                    proto=proto,
                    flags=_NUMERIC_SOCKET_FLAGS,
                )
            )

        return hosts

    async def close(self) -> None:
        pass


class AsyncResolver(AbstractResolver):
    """Use the `aiodns` package to make asynchronous DNS lookups"""

    def __init__(
        self,
        loop: Optional[asyncio.AbstractEventLoop] = None,
        *args: Any,
        **kwargs: Any
    ) -> None:
        if aiodns is None:
            raise RuntimeError("Resolver requires aiodns library")

        self._resolver = aiodns.DNSResolver(*args, **kwargs)

        if not hasattr(self._resolver, "gethostbyname"):
            # aiodns 1.1 is not available, fallback to DNSResolver.query
            self.resolve = self._resolve_with_query  # type: ignore

    async def resolve(
        self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET
    ) -> List[ResolveResult]:
        try:
            resp = await self._resolver.getaddrinfo(
                host,
                port=port,
                type=socket.SOCK_STREAM,
                family=family,
                flags=socket.AI_ADDRCONFIG,
            )
        except aiodns.error.DNSError as exc:
            msg = exc.args[1] if len(exc.args) >= 1 else "DNS lookup failed"
            raise OSError(None, msg) from exc
        hosts: List[ResolveResult] = []
        for node in resp.nodes:
            address: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]] = node.addr
            family = node.family
            if family == socket.AF_INET6:
                if len(address) > 3 and address[3] and _SUPPORTS_SCOPE_ID:
                    # This is essential for link-local IPv6 addresses.
                    # LL IPv6 is a VERY rare case. Strictly speaking, we should use
                    # getnameinfo() unconditionally, but performance makes sense.
                    result = await self._resolver.getnameinfo(
                        (address[0].decode("ascii"), *address[1:]),
                        _NAME_SOCKET_FLAGS,
                    )
                    resolved_host = result.node
                else:
                    resolved_host = address[0].decode("ascii")
                    port = address[1]
            else:  # IPv4
                assert family == socket.AF_INET
                resolved_host = address[0].decode("ascii")
                port = address[1]
            hosts.append(
                ResolveResult(
                    hostname=host,
                    host=resolved_host,
                    port=port,
                    family=family,
                    proto=0,
                    flags=_NUMERIC_SOCKET_FLAGS,
                )
            )

        if not hosts:
            raise OSError(None, "DNS lookup failed")

        return hosts

    async def _resolve_with_query(
        self, host: str, port: int = 0, family: int = socket.AF_INET
    ) -> List[Dict[str, Any]]:
        if family == socket.AF_INET6:
            qtype = "AAAA"
        else:
            qtype = "A"

        try:
            resp = await self._resolver.query(host, qtype)
        except aiodns.error.DNSError as exc:
            msg = exc.args[1] if len(exc.args) >= 1 else "DNS lookup failed"
            raise OSError(msg) from exc

        hosts = []
        for rr in resp:
            hosts.append(
                {
                    "hostname": host,
                    "host": rr.host,
                    "port": port,
                    "family": family,
                    "proto": 0,
                    "flags": socket.AI_NUMERICHOST,
                }
            )

        if not hosts:
            raise OSError("DNS lookup failed")

        return hosts

    async def close(self) -> None:
        self._resolver.cancel()


_DefaultType = Type[Union[AsyncResolver, ThreadedResolver]]
DefaultResolver: _DefaultType = AsyncResolver if aiodns_default else ThreadedResolver

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
[ISSUE]
**Title:** AsyncResolver Fallback Suppresses DNS Error Messages

**Description:**
When a DNS query fallback occurs in `AsyncResolver`, the raised `OSError` does not include the original error message. This makes it difficult to understand the reason behind the DNS lookup failure.

**Example Code:**
```python
import asyncio
from aiohttp.resolver import AsyncResolver

async def resolve_host():
    resolver = AsyncResolver()
    try:
        await resolver.resolve("invalid.host")
    except OSError as e:
        print(f"Error message: {e.strerror}")

asyncio.run(resolve_host())
```

**Expected Behavior:**
When resolving an invalid hostname, the `OSError` should contain the specific error message from the DNS resolver, allowing developers to see details about why the DNS lookup failed.

**Actual Behavior:**
The `OSError` is raised with `strerror` set to `None`, resulting in no error message being displayed:
```
Error message: None
```
[/ISSUE]
{
    "test_async_resolver_positive_ipv4_lookup[pyloop]": "PASSED",
    "test_async_resolver_positive_link_local_ipv6_lookup[pyloop]": "PASSED",
    "test_async_resolver_multiple_replies[pyloop]": "PASSED",
    "test_async_resolver_query_multiple_replies[pyloop]": "PASSED",
    "test_async_resolver_negative_lookup[pyloop]": "PASSED",
    "test_async_resolver_no_hosts_in_getaddrinfo[pyloop]": "PASSED",
    "test_threaded_resolver_positive_lookup": "PASSED",
    "test_threaded_resolver_positive_ipv6_link_local_lookup": "PASSED",
    "test_threaded_resolver_multiple_replies": "PASSED",
    "test_threaded_negative_lookup": "PASSED",
    "test_threaded_negative_ipv6_lookup": "PASSED",
    "test_threaded_negative_lookup_with_unknown_result": "PASSED",
    "test_close_for_threaded_resolver[pyloop]": "PASSED",
    "test_close_for_async_resolver[pyloop]": "PASSED",
    "test_default_loop_for_threaded_resolver[pyloop]": "PASSED",
    "test_async_resolver_ipv6_positive_lookup[pyloop]": "PASSED",
    "test_async_resolver_query_ipv6_positive_lookup[pyloop]": "PASSED",
    "test_async_resolver_query_fallback_error_messages_passed[pyloop]": "PASSED",
    "test_async_resolver_query_fallback_error_messages_passed_no_hosts[pyloop]": "PASSED",
    "test_async_resolver_error_messages_passed[pyloop]": "PASSED",
    "test_async_resolver_error_messages_passed_no_hosts[pyloop]": "PASSED",
    "test_async_resolver_aiodns_not_present[pyloop]": "PASSED",
    "test_aio_dns_is_default": "PASSED"
}
diff --git a/aiohttp/resolver.py b/aiohttp/resolver.py
index 385ae21a..c01a46fb 100644
--- a/aiohttp/resolver.py
+++ b/aiohttp/resolver.py
@@ -161,7 +161,7 @@ class AsyncResolver(AbstractResolver):
             resp = await self._resolver.query(host, qtype)
         except aiodns.error.DNSError as exc:
             msg = exc.args[1] if len(exc.args) >= 1 else "DNS lookup failed"
-            raise OSError(msg) from exc
+            raise OSError(None, msg) from exc
 
         hosts = []
         for rr in resp:
@@ -177,7 +177,7 @@ class AsyncResolver(AbstractResolver):
             )
 
         if not hosts:
-            raise OSError("DNS lookup failed")
+            raise OSError(None, "DNS lookup failed")
 
         return hosts
 

{"aiohttp/resolver.py": "import asyncio\nimport socket\nimport sys\nfrom typing import Any, Dict, List, Optional, Tuple, Type, Union\n\nfrom .abc import AbstractResolver, ResolveResult\n\n__all__ = (\"ThreadedResolver\", \"AsyncResolver\", \"DefaultResolver\")\n\n\ntry:\n    import aiodns\n\n    aiodns_default = hasattr(aiodns.DNSResolver, \"getaddrinfo\")\nexcept ImportError:  # pragma: no cover\n    aiodns = None  # type: ignore[assignment]\n    aiodns_default = False\n\n\n_NUMERIC_SOCKET_FLAGS = socket.AI_NUMERICHOST | socket.AI_NUMERICSERV\n_NAME_SOCKET_FLAGS = socket.NI_NUMERICHOST | socket.NI_NUMERICSERV\n_SUPPORTS_SCOPE_ID = sys.version_info >= (3, 9, 0)\n\n\nclass ThreadedResolver(AbstractResolver):\n    \"\"\"Threaded resolver.\n\n    Uses an Executor for synchronous getaddrinfo() calls.\n    concurrent.futures.ThreadPoolExecutor is used by default.\n    \"\"\"\n\n    def __init__(self, loop: Optional[asyncio.AbstractEventLoop] = None) -> None:\n        self._loop = loop or asyncio.get_running_loop()\n\n    async def resolve(\n        self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET\n    ) -> List[ResolveResult]:\n        infos = await self._loop.getaddrinfo(\n            host,\n            port,\n            type=socket.SOCK_STREAM,\n            family=family,\n            flags=socket.AI_ADDRCONFIG,\n        )\n\n        hosts: List[ResolveResult] = []\n        for family, _, proto, _, address in infos:\n            if family == socket.AF_INET6:\n                if len(address) < 3:\n                    # IPv6 is not supported by Python build,\n                    # or IPv6 is not enabled in the host\n                    continue\n                if address[3] and _SUPPORTS_SCOPE_ID:\n                    # This is essential for link-local IPv6 addresses.\n                    # LL IPv6 is a VERY rare case. Strictly speaking, we should use\n                    # getnameinfo() unconditionally, but performance makes sense.\n                    resolved_host, _port = await self._loop.getnameinfo(\n                        address, _NAME_SOCKET_FLAGS\n                    )\n                    port = int(_port)\n                else:\n                    resolved_host, port = address[:2]\n            else:  # IPv4\n                assert family == socket.AF_INET\n                resolved_host, port = address  # type: ignore[misc]\n            hosts.append(\n                ResolveResult(\n                    hostname=host,\n                    host=resolved_host,\n                    port=port,\n                    family=family,\n                    proto=proto,\n                    flags=_NUMERIC_SOCKET_FLAGS,\n                )\n            )\n\n        return hosts\n\n    async def close(self) -> None:\n        pass\n\n\nclass AsyncResolver(AbstractResolver):\n    \"\"\"Use the `aiodns` package to make asynchronous DNS lookups\"\"\"\n\n    def __init__(\n        self,\n        loop: Optional[asyncio.AbstractEventLoop] = None,\n        *args: Any,\n        **kwargs: Any\n    ) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\n\n        if not hasattr(self._resolver, \"gethostbyname\"):\n            # aiodns 1.1 is not available, fallback to DNSResolver.query\n            self.resolve = self._resolve_with_query  # type: ignore\n\n    async def resolve(\n        self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET\n    ) -> List[ResolveResult]:\n        try:\n            resp = await self._resolver.getaddrinfo(\n                host,\n                port=port,\n                type=socket.SOCK_STREAM,\n                family=family,\n                flags=socket.AI_ADDRCONFIG,\n            )\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(None, msg) from exc\n        hosts: List[ResolveResult] = []\n        for node in resp.nodes:\n            address: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]] = node.addr\n            family = node.family\n            if family == socket.AF_INET6:\n                if len(address) > 3 and address[3] and _SUPPORTS_SCOPE_ID:\n                    # This is essential for link-local IPv6 addresses.\n                    # LL IPv6 is a VERY rare case. Strictly speaking, we should use\n                    # getnameinfo() unconditionally, but performance makes sense.\n                    result = await self._resolver.getnameinfo(\n                        (address[0].decode(\"ascii\"), *address[1:]),\n                        _NAME_SOCKET_FLAGS,\n                    )\n                    resolved_host = result.node\n                else:\n                    resolved_host = address[0].decode(\"ascii\")\n                    port = address[1]\n            else:  # IPv4\n                assert family == socket.AF_INET\n                resolved_host = address[0].decode(\"ascii\")\n                port = address[1]\n            hosts.append(\n                ResolveResult(\n                    hostname=host,\n                    host=resolved_host,\n                    port=port,\n                    family=family,\n                    proto=0,\n                    flags=_NUMERIC_SOCKET_FLAGS,\n                )\n            )\n\n        if not hosts:\n            raise OSError(None, \"DNS lookup failed\")\n\n        return hosts\n\n    async def _resolve_with_query(\n        self, host: str, port: int = 0, family: int = socket.AF_INET\n    ) -> List[Dict[str, Any]]:\n        if family == socket.AF_INET6:\n            qtype = \"AAAA\"\n        else:\n            qtype = \"A\"\n\n        try:\n            resp = await self._resolver.query(host, qtype)\n        except aiodns.error.DNSError as exc:\n            msg = exc.args[1] if len(exc.args) >= 1 else \"DNS lookup failed\"\n            raise OSError(msg) from exc\n\n        hosts = []\n        for rr in resp:\n            hosts.append(\n                {\n                    \"hostname\": host,\n                    \"host\": rr.host,\n                    \"port\": port,\n                    \"family\": family,\n                    \"proto\": 0,\n                    \"flags\": socket.AI_NUMERICHOST,\n                }\n            )\n\n        if not hosts:\n            raise OSError(\"DNS lookup failed\")\n\n        return hosts\n\n    async def close(self) -> None:\n        self._resolver.cancel()\n\n\n_DefaultType = Type[Union[AsyncResolver, ThreadedResolver]]\nDefaultResolver: _DefaultType = AsyncResolver if aiodns_default else ThreadedResolver\n"}
A user will ask you to solve a task. You should first draft your thinking process (inner monologue). Then, generate the solution.

Your response format must follow the template below:
<think>
Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate a correct solution.
</think>
<solution>
Final solution presented to the user.
</solution>
system
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** AsyncResolver Fallback Suppresses DNS Error Messages

**Description:**
When a DNS query fallback occurs in `AsyncResolver`, the raised `OSError` does not include the original error message. This makes it difficult to understand the reason behind the DNS lookup failure.

**Example Code:**
```python
import asyncio
from aiohttp.resolver import AsyncResolver

async def resolve_host():
    resolver = AsyncResolver()
    try:
        await resolver.resolve("invalid.host")
    except OSError as e:
        print(f"Error message: {e.strerror}")

asyncio.run(resolve_host())
```

**Expected Behavior:**
When resolving an invalid hostname, the `OSError` should contain the specific error message from the DNS resolver, allowing developers to see details about why the DNS lookup failed.

**Actual Behavior:**
The `OSError` is raised with `strerror` set to `None`, resulting in no error message being displayed:
```
Error message: None
```
[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### aiohttp/resolver.py
import asyncio
import socket
import sys
from typing import Any, Dict, List, Optional, Tuple, Type, Union

from .abc import AbstractResolver, ResolveResult

__all__ = ("ThreadedResolver", "AsyncResolver", "DefaultResolver")


try:
    import aiodns

    aiodns_default = hasattr(aiodns.DNSResolver, "getaddrinfo")
except ImportError:  # pragma: no cover
    aiodns = None  # type: ignore[assignment]
    aiodns_default = False


_NUMERIC_SOCKET_FLAGS = socket.AI_NUMERICHOST | socket.AI_NUMERICSERV
_NAME_SOCKET_FLAGS = socket.NI_NUMERICHOST | socket.NI_NUMERICSERV
_SUPPORTS_SCOPE_ID = sys.version_info >= (3, 9, 0)


class ThreadedResolver(AbstractResolver):
    """Threaded resolver.

    Uses an Executor for synchronous getaddrinfo() calls.
    concurrent.futures.ThreadPoolExecutor is used by default.
    """

    def __init__(self, loop: Optional[asyncio.AbstractEventLoop] = None) -> None:
        self._loop = loop or asyncio.get_running_loop()

    async def resolve(
        self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET
    ) -> List[ResolveResult]:
        infos = await self._loop.getaddrinfo(
            host,
            port,
            type=socket.SOCK_STREAM,
            family=family,
            flags=socket.AI_ADDRCONFIG,
        )

        hosts: List[ResolveResult] = []
        for family, _, proto, _, address in infos:
            if family == socket.AF_INET6:
                if len(address) < 3:
                    # IPv6 is not supported by Python build,
                    # or IPv6 is not enabled in the host
                    continue
                if address[3] and _SUPPORTS_SCOPE_ID:
                    # This is essential for link-local IPv6 addresses.
                    # LL IPv6 is a VERY rare case. Strictly speaking, we should use
                    # getnameinfo() unconditionally, but performance makes sense.
                    resolved_host, _port = await self._loop.getnameinfo(
                        address, _NAME_SOCKET_FLAGS
                    )
                    port = int(_port)
                else:
                    resolved_host, port = address[:2]
            else:  # IPv4
                assert family == socket.AF_INET
                resolved_host, port = address  # type: ignore[misc]
            hosts.append(
                ResolveResult(
                    hostname=host,
                    host=resolved_host,
                    port=port,
                    family=family,
                    proto=proto,
                    flags=_NUMERIC_SOCKET_FLAGS,
                )
            )

        return hosts

    async def close(self) -> None:
        pass


class AsyncResolver(AbstractResolver):
    """Use the `aiodns` package to make asynchronous DNS lookups"""

    def __init__(
        self,
        loop: Optional[asyncio.AbstractEventLoop] = None,
        *args: Any,
        **kwargs: Any
    ) -> None:
        if aiodns is None:
            raise RuntimeError("Resolver requires aiodns library")

        self._resolver = aiodns.DNSResolver(*args, **kwargs)

        if not hasattr(self._resolver, "gethostbyname"):
            # aiodns 1.1 is not available, fallback to DNSResolver.query
            self.resolve = self._resolve_with_query  # type: ignore

    async def resolve(
        self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET
    ) -> List[ResolveResult]:
        try:
            resp = await self._resolver.getaddrinfo(
                host,
                port=port,
                type=socket.SOCK_STREAM,
                family=family,
                flags=socket.AI_ADDRCONFIG,
            )
        except aiodns.error.DNSError as exc:
            msg = exc.args[1] if len(exc.args) >= 1 else "DNS lookup failed"
            raise OSError(None, msg) from exc
        hosts: List[ResolveResult] = []
        for node in resp.nodes:
            address: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]] = node.addr
            family = node.family
            if family == socket.AF_INET6:
                if len(address) > 3 and address[3] and _SUPPORTS_SCOPE_ID:
                    # This is essential for link-local IPv6 addresses.
                    # LL IPv6 is a VERY rare case. Strictly speaking, we should use
                    # getnameinfo() unconditionally, but performance makes sense.
                    result = await self._resolver.getnameinfo(
                        (address[0].decode("ascii"), *address[1:]),
                        _NAME_SOCKET_FLAGS,
                    )
                    resolved_host = result.node
                else:
                    resolved_host = address[0].decode("ascii")
                    port = address[1]
            else:  # IPv4
                assert family == socket.AF_INET
                resolved_host = address[0].decode("ascii")
                port = address[1]
            hosts.append(
                ResolveResult(
                    hostname=host,
                    host=resolved_host,
                    port=port,
                    family=family,
                    proto=0,
                    flags=_NUMERIC_SOCKET_FLAGS,
                )
            )

        if not hosts:
            raise OSError(None, "DNS lookup failed")

        return hosts

    async def _resolve_with_query(
        self, host: str, port: int = 0, family: int = socket.AF_INET
    ) -> List[Dict[str, Any]]:
        if family == socket.AF_INET6:
            qtype = "AAAA"
        else:
            qtype = "A"

        try:
            resp = await self._resolver.query(host, qtype)
        except aiodns.error.DNSError as exc:
            msg = exc.args[1] if len(exc.args) >= 1 else "DNS lookup failed"
            raise OSError(msg) from exc

        hosts = []
        for rr in resp:
            hosts.append(
                {
                    "hostname": host,
                    "host": rr.host,
                    "port": port,
                    "family": family,
                    "proto": 0,
                    "flags": socket.AI_NUMERICHOST,
                }
            )

        if not hosts:
            raise OSError("DNS lookup failed")

        return hosts

    async def close(self) -> None:
        self._resolver.cancel()


_DefaultType = Type[Union[AsyncResolver, ThreadedResolver]]
DefaultResolver: _DefaultType = AsyncResolver if aiodns_default else ThreadedResolver

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
user