{
    "file_diffs": [
        {
            "old_file_content": "",
            "new_file_content": "Fixed error messages from :py:class:`~aiohttp.resolver.AsyncResolver` being swallowed -- by :user:`bdraco`.\n",
            "header": {
                "file": {
                    "path": "CHANGES/9451.bugfix.rst"
                },
                "misc_line": "new file mode 100644"
            },
            "index_line": {
                "old_commit_hash": "00000000",
                "new_commit_hash": "2adcbc66",
                "mode": ""
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "/dev/null"
            },
            "plus_file": {
                "path": "b/CHANGES/9451.bugfix.rst"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 0,
                            "length": 0
                        },
                        "new_range": {
                            "start": 1,
                            "length": null
                        },
                        "section": ""
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "Fixed error messages from :py:class:`~aiohttp.resolver.AsyncResolver` being swallowed -- by :user:`bdraco`.",
                                "type": "added"
                            }
                        ]
                    },
                    "modified_entities": [],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "import asyncio\nimport socket\nfrom typing import Any, List, 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\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) -> None:\n        self._loop = 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]:\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__(self, *args: Any, **kwargs: Any) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\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(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]:\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(\"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\nfrom typing import Any, List, 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\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) -> None:\n        self._loop = 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]:\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__(self, *args: Any, **kwargs: Any) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\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]:\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 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": "daa90b82",
                "new_commit_hash": "1025df06",
                "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": 100,
                            "length": 7
                        },
                        "new_range": {
                            "start": 100,
                            "length": 7
                        },
                        "section": "class AsyncResolver(AbstractResolver):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "            )",
                                "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": "        hosts: List[ResolveResult] = []",
                                "type": "context"
                            },
                            {
                                "content": "        for node in resp.nodes:",
                                "type": "context"
                            },
                            {
                                "content": "            address: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]] = node.addr",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "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__(self, *args: Any, **kwargs: Any) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\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(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]:\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(\"DNS lookup failed\")\n\n        return hosts\n\n    async def close(self) -> None:\n        self._resolver.cancel()",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 81,
                            "end_lineno": 142,
                            "parent": null
                        },
                        {
                            "file_name": "aiohttp/resolver.py",
                            "type": "method",
                            "name": "AsyncResolver.resolve",
                            "content": "class AsyncResolver(AbstractResolver):\n    \"\"\"Use the `aiodns` package to make asynchronous DNS lookups\"\"\"\n\n    def __init__(self, *args: Any, **kwargs: Any) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\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(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]:\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(\"DNS lookup failed\")\n\n        return hosts\n\n    async def close(self) -> None:\n        self._resolver.cancel()",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 90,
                            "end_lineno": 139,
                            "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__(self, *args: Any, **kwargs: Any) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\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(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]:\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(\"DNS lookup failed\")\n\n        return hosts\n\n    async def close(self) -> None:\n        self._resolver.cancel()",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 81,
                                "end_lineno": 142,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 134,
                            "length": 7
                        },
                        "new_range": {
                            "start": 134,
                            "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": "class",
                            "name": "AsyncResolver",
                            "content": "class AsyncResolver(AbstractResolver):\n    \"\"\"Use the `aiodns` package to make asynchronous DNS lookups\"\"\"\n\n    def __init__(self, *args: Any, **kwargs: Any) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\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(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]:\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(\"DNS lookup failed\")\n\n        return hosts\n\n    async def close(self) -> None:\n        self._resolver.cancel()",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 81,
                            "end_lineno": 142,
                            "parent": null
                        },
                        {
                            "file_name": "aiohttp/resolver.py",
                            "type": "method",
                            "name": "AsyncResolver.resolve",
                            "content": "class AsyncResolver(AbstractResolver):\n    \"\"\"Use the `aiodns` package to make asynchronous DNS lookups\"\"\"\n\n    def __init__(self, *args: Any, **kwargs: Any) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\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(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]:\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(\"DNS lookup failed\")\n\n        return hosts\n\n    async def close(self) -> None:\n        self._resolver.cancel()",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 90,
                            "end_lineno": 139,
                            "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__(self, *args: Any, **kwargs: Any) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\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(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]:\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(\"DNS lookup failed\")\n\n        return hosts\n\n    async def close(self) -> None:\n        self._resolver.cancel()",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 81,
                                "end_lineno": 142,
                                "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    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    host: Any\n\n    def __init__(self, host: Any) -> None:\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: Any) -> List[FakeQueryResult]:\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\")\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        ipaddrs = [ipaddress.ip_address(x[\"host\"]) for x in real]\n        assert len(ipaddrs) > 3, \"Expecting multiple addresses\"\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()\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\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()\n    resolver._loop = loop\n    real = await resolver.resolve(\"www.google.com\")\n    ipaddrs = [ipaddress.ip_address(x[\"host\"]) for x in real]\n    assert len(ipaddrs) > 3, \"Expecting multiple addresses\"\n\n\nasync def test_threaded_negative_lookup() -> None:\n    loop = Mock()\n    ips: List[Any] = []\n    loop.getaddrinfo = fake_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_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: Any) -> 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: Any) -> None:\n    resolver = AsyncResolver()\n    await resolver.close()\n\n\nasync def test_default_loop_for_threaded_resolver(loop: Any) -> 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\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()\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    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    host: Any\n\n    def __init__(self, host: Any) -> None:\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: Any) -> List[FakeQueryResult]:\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\")\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        ipaddrs = [ipaddress.ip_address(x[\"host\"]) for x in real]\n        assert len(ipaddrs) > 3, \"Expecting multiple addresses\"\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()\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\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()\n    resolver._loop = loop\n    real = await resolver.resolve(\"www.google.com\")\n    ipaddrs = [ipaddress.ip_address(x[\"host\"]) for x in real]\n    assert len(ipaddrs) > 3, \"Expecting multiple addresses\"\n\n\nasync def test_threaded_negative_lookup() -> None:\n    loop = Mock()\n    ips: List[Any] = []\n    loop.getaddrinfo = fake_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_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: Any) -> 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: Any) -> None:\n    resolver = AsyncResolver()\n    await resolver.close()\n\n\nasync def test_default_loop_for_threaded_resolver(loop: Any) -> 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(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()\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": "8ca7d329",
                "new_commit_hash": "701f0a45",
                "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": 315,
                            "length": 6
                        },
                        "new_range": {
                            "start": 315,
                            "length": 34
                        },
                        "section": "async def test_async_resolver_ipv6_positive_lookup(loop: Any) -> None:"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        )",
                                "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_error_messages_passed(",
                                "type": "added"
                            },
                            {
                                "content": "    loop: asyncio.AbstractEventLoop,",
                                "type": "added"
                            },
                            {
                                "content": ") -> None:",
                                "type": "added"
                            },
                            {
                                "content": "    \"\"\"Ensure error messages are passed through from aiodns.\"\"\"",
                                "type": "added"
                            },
                            {
                                "content": "    with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:",
                                "type": "added"
                            },
                            {
                                "content": "        mock().getaddrinfo.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_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.\"\"\"",
                                "type": "added"
                            },
                            {
                                "content": "    with patch(\"aiodns.DNSResolver\", autospec=True, spec_set=True) as mock:",
                                "type": "added"
                            },
                            {
                                "content": "        mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv6_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": "async def test_async_resolver_aiodns_not_present(loop: Any, monkeypatch: Any) -> None:",
                                "type": "context"
                            },
                            {
                                "content": "    monkeypatch.setattr(\"aiohttp.resolver.aiodns\", None)",
                                "type": "context"
                            },
                            {
                                "content": "    with pytest.raises(RuntimeError):",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [],
                    "added_entities": [
                        {
                            "file_name": "tests/test_resolver.py",
                            "type": "function",
                            "name": "test_async_resolver_error_messages_passed",
                            "content": "async 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\"",
                            "ast_type_str": "AsyncFunctionDef",
                            "start_lineno": 319,
                            "end_lineno": 329,
                            "parent": null
                        },
                        {
                            "file_name": "tests/test_resolver.py",
                            "type": "function",
                            "name": "test_async_resolver_error_messages_passed_no_hosts",
                            "content": "async 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\"",
                            "ast_type_str": "AsyncFunctionDef",
                            "start_lineno": 333,
                            "end_lineno": 343,
                            "parent": null
                        }
                    ],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "216e082807d02fafaacca57fc883c86826b126d3^",
    "new_commit_hash": "216e082807d02fafaacca57fc883c86826b126d3",
    "commit_message": "Fix AsyncResolver swallowing the error message (#9451)",
    "commit_date": "2024-10-10T14:08:28Z",
    "metadata": {}
}
{
    "repo_name": "aiohttp",
    "new_commit_hash": "216e082807d02fafaacca57fc883c86826b126d3",
    "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    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    host: Any\n\n    def __init__(self, host: Any) -> None:\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: Any) -> List[FakeQueryResult]:\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\")\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        ipaddrs = [ipaddress.ip_address(x[\"host\"]) for x in real]\n        assert len(ipaddrs) > 3, \"Expecting multiple addresses\"\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()\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\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()\n    resolver._loop = loop\n    real = await resolver.resolve(\"www.google.com\")\n    ipaddrs = [ipaddress.ip_address(x[\"host\"]) for x in real]\n    assert len(ipaddrs) > 3, \"Expecting multiple addresses\"\n\n\nasync def test_threaded_negative_lookup() -> None:\n    loop = Mock()\n    ips: List[Any] = []\n    loop.getaddrinfo = fake_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_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: Any) -> 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: Any) -> None:\n    resolver = AsyncResolver()\n    await resolver.close()\n\n\nasync def test_default_loop_for_threaded_resolver(loop: Any) -> 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(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()\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",
        "# type: ignore\nimport 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, List\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: List[str] = [\"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() -> trustme.CA:\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: Any) -> Any:\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: Any) -> ssl.SSLContext:\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: Any) -> ssl.SSLContext:\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: Any) -> None:\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: Any) -> None:\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: Any) -> bytes:\n    return tls_certificate.cert_chain_pems[0].bytes()\n\n\n@pytest.fixture\ndef tls_certificate_fingerprint_sha256(tls_certificate_pem_bytes: Any) -> 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 pipe_name() -> str:\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) -> ResponseHandler:\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 unix_sockname(tmp_path: Any, tmp_path_factory: Any):\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 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    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    # Ref: https://unix.stackexchange.com/a/367012/27133\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 selector_loop() -> None:\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() -> bytes:\n    return os.urandom(16)\n\n\n@pytest.fixture\ndef key(key_data: bytes) -> bytes:\n    return base64.b64encode(key_data)\n\n\n@pytest.fixture\ndef ws_key(key: bytes) -> bytes:\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_216e082807d02fafaacca57fc883c86826b126d3/requirements/cython.txt\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/tools/gen.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/hdrs.py\n./tools/gen.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/_http_parser.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/_http_writer.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/_websocket.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/_cparser.pxd\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/_find_header.pxd\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 6s\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_216e082807d02fafaacca57fc883c86826b126d3/vendor/llhttp'\nnpx ts-node bin/generate.ts\nmake[1]: Leaving directory '/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/vendor/llhttp'\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/__init__.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/abc.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/base_protocol.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/client.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/client_exceptions.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/client_proto.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/client_reqrep.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/client_ws.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/compression_utils.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/connector.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/cookiejar.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/formdata.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/helpers.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/http.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/http_exceptions.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/http_parser.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/http_websocket.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/http_writer.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/locks.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/log.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/multipart.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/payload.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/pytest_plugin.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/resolver.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/streams.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/tcp_helpers.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/test_utils.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/tracing.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/typedefs.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/web.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/web_app.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/web_exceptions.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/web_fileresponse.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/web_log.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/web_middlewares.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/web_protocol.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/web_request.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/web_response.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/web_routedef.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/web_runner.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/web_server.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/web_urldispatcher.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/aiohttp/web_ws.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/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 44ms\nPrepared 1 package in 0.36ms\nInstalled 1 package in 30ms\n + pip==24.3.1\nResolved 3 packages in 15ms\nInstalled 3 packages in 51ms\n + cython==3.0.11\n + multidict==6.1.0\n + typing-extensions==4.12.2\nResolved 93 packages in 103ms\nUninstalled 1 package in 5ms\nInstalled 91 packages in 341ms\n + aiodns==3.2.0\n + aiohappyeyeballs==2.4.3\n + aiohttp-theme==0.1.7\n + aiosignal==1.3.1\n + alabaster==0.7.13\n + annotated-types==0.7.0\n + async-timeout==4.0.3\n + babel==2.16.0\n + brotli==1.1.0\n + build==1.2.2.post1\n + certifi==2024.8.30\n + cffi==1.17.1\n + cfgv==3.4.0\n + charset-normalizer==3.4.0\n + cherry-picker==2.2.0\n + click==8.1.7\n + coverage==7.6.1\n + cryptography==43.0.1\n + distlib==0.3.9\n + docutils==0.20.1\n + exceptiongroup==1.2.2\n + filelock==3.16.1\n + freezegun==1.5.1\n + frozenlist==1.4.1\n + gidgethub==5.3.0\n + gunicorn==23.0.0\n + identify==2.6.1\n + idna==3.6\n + imagesize==1.4.1\n + importlib-metadata==8.5.0\n + importlib-resources==6.4.5\n + incremental==24.7.2\n + iniconfig==2.0.0\n + jinja2==3.1.4\n + markdown-it-py==3.0.0\n + markupsafe==2.1.5\n + mdurl==0.1.2\n + mypy==1.11.2\n + mypy-extensions==1.0.0\n + nodeenv==1.9.1\n + packaging==24.1\n - pip==24.3.1\n + pip==24.2\n + pip-tools==7.4.1\n + platformdirs==4.3.6\n + pluggy==1.5.0\n + pre-commit==3.5.0\n + propcache==0.2.0\n + proxy-py==2.4.8\n + pycares==4.4.0\n + pycparser==2.22\n + pydantic==2.9.2\n + pydantic-core==2.23.4\n + pygments==2.18.0\n + pyjwt==2.8.0\n + pyproject-hooks==1.2.0\n + pytest==8.1.1\n + pytest-cov==5.0.0\n + pytest-mock==3.14.0\n + python-dateutil==2.9.0.post0\n + python-on-whales==0.73.0\n + pyyaml==6.0.2\n + requests==2.32.3\n + rich==13.9.2\n + setuptools==75.1.0\n + setuptools-git==1.2\n + shellingham==1.5.4\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-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.2\n + towncrier==23.11.0\n + tqdm==4.66.5\n + trustme==1.1.0\n + typer==0.12.5\n + uritemplate==4.1.1\n + urllib3==2.2.3\n + uvloop==0.21.0b1\n + valkey==6.0.2\n + virtualenv==20.26.6\n + wait-for-it==2.2.2\n + wheel==0.44.0\n + yarl==1.14.0\n + zipp==3.20.2\nResolved 10 packages in 1.79s\nPrepared 1 package in 14.99s\nInstalled 1 package in 0.55ms\n + aiohttp==4.0.0a2.dev0 (from file:///home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3)\nResolved 26 packages in 14ms\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.23.8\n",
    "new_commit_res_code": 0,
    "new_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.9.21, pytest-8.1.1, pluggy-1.5.0 -- /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/.venv/bin/python\ncachedir: .pytest_cache\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3\nconfigfile: setup.cfg\nplugins: cov-5.0.0, mock-3.14.0, asyncio-0.23.8\nasyncio: mode=strict\ncollecting ... collected 20 items\n\nr2e_tests/test_1.py::test_async_resolver_positive_ipv4_lookup[pyloop] PASSED [  5%]\nr2e_tests/test_1.py::test_async_resolver_positive_link_local_ipv6_lookup[pyloop] PASSED [ 10%]\nr2e_tests/test_1.py::test_async_resolver_multiple_replies[pyloop] PASSED [ 15%]\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       [ 30%]\nr2e_tests/test_1.py::test_threaded_resolver_positive_ipv6_link_local_lookup PASSED [ 35%]\nr2e_tests/test_1.py::test_threaded_resolver_multiple_replies PASSED      [ 40%]\nr2e_tests/test_1.py::test_threaded_negative_lookup PASSED                [ 45%]\nr2e_tests/test_1.py::test_threaded_negative_ipv6_lookup PASSED           [ 50%]\nr2e_tests/test_1.py::test_threaded_negative_lookup_with_unknown_result PASSED [ 55%]\nr2e_tests/test_1.py::test_close_for_threaded_resolver[pyloop] PASSED     [ 60%]\nr2e_tests/test_1.py::test_close_for_async_resolver[pyloop] PASSED        [ 65%]\nr2e_tests/test_1.py::test_default_loop_for_threaded_resolver[pyloop] PASSED [ 70%]\nr2e_tests/test_1.py::test_async_resolver_ipv6_positive_lookup[pyloop] PASSED [ 75%]\nr2e_tests/test_1.py::test_async_resolver_error_messages_passed[pyloop] PASSED [ 80%]\nr2e_tests/test_1.py::test_async_resolver_error_messages_passed_no_hosts[pyloop] PASSED [ 85%]\nr2e_tests/test_1.py::test_async_resolver_aiodns_not_present[pyloop] PASSED [ 90%]\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                         26     10      2      0    57%\naiohttp/abc.py                              98      7      0      0    93%\naiohttp/base_protocol.py                    68     51     22      0    19%\naiohttp/client.py                          523    383    190      2    20%\naiohttp/client_exceptions.py               139     59     14      0    52%\naiohttp/client_proto.py                    169    136     58      0    15%\naiohttp/client_reqrep.py                   667    498    276      0    18%\naiohttp/client_ws.py                       271    214     82      1    17%\naiohttp/compression_utils.py                70     36     14      0    40%\naiohttp/connector.py                       726    589    315      1    13%\naiohttp/cookiejar.py                       272    216    132      0    14%\naiohttp/formdata.py                         88     71     40      0    13%\naiohttp/hdrs.py                             90      0      0      0   100%\naiohttp/helpers.py                         519    347    196      1    26%\naiohttp/http.py                              8      0      0      0   100%\naiohttp/http_exceptions.py                  48     18      2      0    60%\naiohttp/http_parser.py                     496    397    208      1    14%\naiohttp/http_websocket.py                  376    278    144      0    19%\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                       625    510    268      1    13%\naiohttp/payload.py                         237    113     58      1    44%\naiohttp/pytest_plugin.py                   161     73     42      5    53%\naiohttp/resolver.py                         62      1     18      1    98%\naiohttp/streams.py                         401    313    142      0    16%\naiohttp/tcp_helpers.py                      19     11      6      0    32%\naiohttp/test_utils.py                      303    184     52      4    35%\naiohttp/tracing.py                         193     69     32      0    69%\naiohttp/typedefs.py                         24      0      0      0   100%\naiohttp/web.py                             128     90     54      0    22%\naiohttp/web_app.py                         237    150     50      0    31%\naiohttp/web_exceptions.py                  216     39     28      6    77%\naiohttp/web_fileresponse.py                160    126     52      0    18%\naiohttp/web_log.py                          96     52     14      0    40%\naiohttp/web_middlewares.py                  58     44     22      0    18%\naiohttp/web_protocol.py                    376    311    158      0    13%\naiohttp/web_request.py                     444    298    142      1    26%\naiohttp/web_response.py                    441    329    198      0    18%\naiohttp/web_routedef.py                    100     44     10      0    55%\naiohttp/web_runner.py                      222    132     40      0    34%\naiohttp/web_server.py                       49     26     14      0    37%\naiohttp/web_urldispatcher.py               719    456    155      0    30%\naiohttp/web_ws.py                          387    314    134      1    15%\naiohttp/worker.py                          123    123     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             93     93      2      0     0%\ntests/test_client_exceptions.py            182    182     14      0     0%\ntests/test_client_fingerprint.py            24     24      0      0     0%\ntests/test_client_functional.py           2600   2600     72      0     0%\ntests/test_client_proto.py                 103    103      0      0     0%\ntests/test_client_request.py               799    799     18      0     0%\ntests/test_client_response.py              502    502      6      0     0%\ntests/test_client_session.py               585    585     29      0     0%\ntests/test_client_ws.py                    488    488      2      0     0%\ntests/test_client_ws_functional.py         799    799     22      0     0%\ntests/test_connector.py                   1737   1737     88      0     0%\ntests/test_cookiejar.py                    469    469     28      0     0%\ntests/test_flowcontrol_streams.py           98     98      0      0     0%\ntests/test_formdata.py                      92     92      4      0     0%\ntests/test_helpers.py                      553    553     20      0     0%\ntests/test_http_exceptions.py              110    110     10      0     0%\ntests/test_http_parser.py                 1091   1091     44      0     0%\ntests/test_http_writer.py                  178    178     10      0     0%\ntests/test_imports.py                       34     34      6      0     0%\ntests/test_locks.py                         40     40      0      0     0%\ntests/test_loop.py                          36     36      0      0     0%\ntests/test_multipart.py                    869    869     34      0     0%\ntests/test_multipart_helpers.py            446    446      0      0     0%\ntests/test_payload.py                       80     80      0      0     0%\ntests/test_proxy.py                        358    358      2      0     0%\ntests/test_proxy_functional.py             465    465     20      0     0%\ntests/test_pytest_plugin.py                 47     47      0      0     0%\ntests/test_resolver.py                     199    199     18      0     0%\ntests/test_route_def.py                    191    191      0      0     0%\ntests/test_run_app.py                      576    576     30      0     0%\ntests/test_streams.py                     1061   1061     38      0     0%\ntests/test_tcp_helpers.py                   52     52      2      0     0%\ntests/test_test_utils.py                   257    257     12      0     0%\ntests/test_tracing.py                       49     49      0      0     0%\ntests/test_urldispatch.py                  862    862     24      0     0%\ntests/test_web_app.py                      383    383      6      0     0%\ntests/test_web_cli.py                       94     94      0      0     0%\ntests/test_web_exceptions.py               277    277     30      0     0%\ntests/test_web_functional.py              1557   1557     24      0     0%\ntests/test_web_log.py                      145    145      4      0     0%\ntests/test_web_middleware.py               245    245      6      0     0%\ntests/test_web_request.py                  544    544      0      0     0%\ntests/test_web_request_handler.py           42     42      0      0     0%\ntests/test_web_response.py                 872    872      6      0     0%\ntests/test_web_runner.py                   179    179      4      0     0%\ntests/test_web_sendfile.py                  85     85      0      0     0%\ntests/test_web_sendfile_functional.py      681    681     18      0     0%\ntests/test_web_server.py                   179    179      0      0     0%\ntests/test_web_urldispatcher.py            511    511     24      0     0%\ntests/test_web_websocket.py                422    422      8      0     0%\ntests/test_web_websocket_functional.py     828    828     24      0     0%\ntests/test_websocket_handshake.py          153    153     12      0     0%\ntests/test_websocket_parser.py             290    290     12      0     0%\ntests/test_websocket_writer.py              96     96      6      0     0%\ntests/test_worker.py                       190    190      2      0     0%\n--------------------------------------------------------------------------\nTOTAL                                    34880  31510   4240     27     9%\n\n============================= slowest 10 durations =============================\n0.02s call     r2e_tests/test_1.py::test_threaded_resolver_positive_ipv6_link_local_lookup\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_positive_ipv4_lookup[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_close_for_threaded_resolver[pyloop]\n0.01s call     r2e_tests/test_1.py::test_threaded_negative_lookup_with_unknown_result\n0.01s call     r2e_tests/test_1.py::test_async_resolver_error_messages_passed_no_hosts[pyloop]\n0.01s call     r2e_tests/test_1.py::test_async_resolver_error_messages_passed[pyloop]\n0.01s teardown r2e_tests/test_1.py::test_async_resolver_ipv6_positive_lookup[pyloop]\n0.01s teardown r2e_tests/test_1.py::test_close_for_async_resolver[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_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_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:357: aiodns <3.2.0 required\n======================== 19 passed, 1 skipped in 4.82s =========================\n",
    "new_commit_res_stderr": "",
    "old_commit_res_code": 1,
    "old_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.9.21, pytest-8.1.1, pluggy-1.5.0 -- /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3/.venv/bin/python\ncachedir: .pytest_cache\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_216e082807d02fafaacca57fc883c86826b126d3\nconfigfile: setup.cfg\nplugins: cov-5.0.0, mock-3.14.0, asyncio-0.23.8\nasyncio: mode=strict\ncollecting ... collected 20 items\n\nr2e_tests/test_1.py::test_async_resolver_positive_ipv4_lookup[pyloop] PASSED [  5%]\nr2e_tests/test_1.py::test_async_resolver_positive_link_local_ipv6_lookup[pyloop] PASSED [ 10%]\nr2e_tests/test_1.py::test_async_resolver_multiple_replies[pyloop] PASSED [ 15%]\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       [ 30%]\nr2e_tests/test_1.py::test_threaded_resolver_positive_ipv6_link_local_lookup PASSED [ 35%]\nr2e_tests/test_1.py::test_threaded_resolver_multiple_replies PASSED      [ 40%]\nr2e_tests/test_1.py::test_threaded_negative_lookup PASSED                [ 45%]\nr2e_tests/test_1.py::test_threaded_negative_ipv6_lookup PASSED           [ 50%]\nr2e_tests/test_1.py::test_threaded_negative_lookup_with_unknown_result PASSED [ 55%]\nr2e_tests/test_1.py::test_close_for_threaded_resolver[pyloop] PASSED     [ 60%]\nr2e_tests/test_1.py::test_close_for_async_resolver[pyloop] PASSED        [ 65%]\nr2e_tests/test_1.py::test_default_loop_for_threaded_resolver[pyloop] PASSED [ 70%]\nr2e_tests/test_1.py::test_async_resolver_ipv6_positive_lookup[pyloop] PASSED [ 75%]\nr2e_tests/test_1.py::test_async_resolver_error_messages_passed[pyloop] FAILED [ 80%]\nr2e_tests/test_1.py::test_async_resolver_error_messages_passed_no_hosts[pyloop] FAILED [ 85%]\nr2e_tests/test_1.py::test_async_resolver_aiodns_not_present[pyloop] PASSED [ 90%]\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_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_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\"\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='126286017486608'>\nresolver   = <aiohttp.resolver.AsyncResolver object at 0x72db412b5850>\n\nr2e_tests/test_1.py:329: AssertionError\n__________ test_async_resolver_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_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\"\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='126286016936688'>\nresolver   = <aiohttp.resolver.AsyncResolver object at 0x72db412e47f0>\n\nr2e_tests/test_1.py:343: AssertionError\n==================================== PASSES ====================================\n\n---------- coverage: platform linux, python 3.9.21-final-0 -----------\nName                                     Stmts   Miss Branch BrPart  Cover\n--------------------------------------------------------------------------\naiohttp/__init__.py                         26     10      2      0    57%\naiohttp/abc.py                              98      7      0      0    93%\naiohttp/base_protocol.py                    68     51     22      0    19%\naiohttp/client.py                          523    383    190      2    20%\naiohttp/client_exceptions.py               139     59     14      0    52%\naiohttp/client_proto.py                    169    136     58      0    15%\naiohttp/client_reqrep.py                   667    498    276      0    18%\naiohttp/client_ws.py                       271    214     82      1    17%\naiohttp/compression_utils.py                70     36     14      0    40%\naiohttp/connector.py                       726    589    315      1    13%\naiohttp/cookiejar.py                       272    216    132      0    14%\naiohttp/formdata.py                         88     71     40      0    13%\naiohttp/hdrs.py                             90      0      0      0   100%\naiohttp/helpers.py                         519    347    196      1    26%\naiohttp/http.py                              8      0      0      0   100%\naiohttp/http_exceptions.py                  48     18      2      0    60%\naiohttp/http_parser.py                     496    397    208      1    14%\naiohttp/http_websocket.py                  376    278    144      0    19%\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                       625    510    268      1    13%\naiohttp/payload.py                         237    113     58      1    44%\naiohttp/pytest_plugin.py                   161     72     42      5    53%\naiohttp/resolver.py                         62      1     18      1    98%\naiohttp/streams.py                         401    313    142      0    16%\naiohttp/tcp_helpers.py                      19     11      6      0    32%\naiohttp/test_utils.py                      303    184     52      4    35%\naiohttp/tracing.py                         193     69     32      0    69%\naiohttp/typedefs.py                         24      0      0      0   100%\naiohttp/web.py                             128     90     54      0    22%\naiohttp/web_app.py                         237    150     50      0    31%\naiohttp/web_exceptions.py                  216     39     28      6    77%\naiohttp/web_fileresponse.py                160    126     52      0    18%\naiohttp/web_log.py                          96     52     14      0    40%\naiohttp/web_middlewares.py                  58     44     22      0    18%\naiohttp/web_protocol.py                    376    311    158      0    13%\naiohttp/web_request.py                     444    298    142      1    26%\naiohttp/web_response.py                    441    329    198      0    18%\naiohttp/web_routedef.py                    100     44     10      0    55%\naiohttp/web_runner.py                      222    132     40      0    34%\naiohttp/web_server.py                       49     26     14      0    37%\naiohttp/web_urldispatcher.py               719    456    155      0    30%\naiohttp/web_ws.py                          387    314    134      1    15%\naiohttp/worker.py                          123    123     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             93     93      2      0     0%\ntests/test_client_exceptions.py            182    182     14      0     0%\ntests/test_client_fingerprint.py            24     24      0      0     0%\ntests/test_client_functional.py           2600   2600     72      0     0%\ntests/test_client_proto.py                 103    103      0      0     0%\ntests/test_client_request.py               799    799     18      0     0%\ntests/test_client_response.py              502    502      6      0     0%\ntests/test_client_session.py               585    585     29      0     0%\ntests/test_client_ws.py                    488    488      2      0     0%\ntests/test_client_ws_functional.py         799    799     22      0     0%\ntests/test_connector.py                   1737   1737     88      0     0%\ntests/test_cookiejar.py                    469    469     28      0     0%\ntests/test_flowcontrol_streams.py           98     98      0      0     0%\ntests/test_formdata.py                      92     92      4      0     0%\ntests/test_helpers.py                      553    553     20      0     0%\ntests/test_http_exceptions.py              110    110     10      0     0%\ntests/test_http_parser.py                 1091   1091     44      0     0%\ntests/test_http_writer.py                  178    178     10      0     0%\ntests/test_imports.py                       34     34      6      0     0%\ntests/test_locks.py                         40     40      0      0     0%\ntests/test_loop.py                          36     36      0      0     0%\ntests/test_multipart.py                    869    869     34      0     0%\ntests/test_multipart_helpers.py            446    446      0      0     0%\ntests/test_payload.py                       80     80      0      0     0%\ntests/test_proxy.py                        358    358      2      0     0%\ntests/test_proxy_functional.py             465    465     20      0     0%\ntests/test_pytest_plugin.py                 47     47      0      0     0%\ntests/test_resolver.py                     183    183     18      0     0%\ntests/test_route_def.py                    191    191      0      0     0%\ntests/test_run_app.py                      576    576     30      0     0%\ntests/test_streams.py                     1061   1061     38      0     0%\ntests/test_tcp_helpers.py                   52     52      2      0     0%\ntests/test_test_utils.py                   257    257     12      0     0%\ntests/test_tracing.py                       49     49      0      0     0%\ntests/test_urldispatch.py                  862    862     24      0     0%\ntests/test_web_app.py                      383    383      6      0     0%\ntests/test_web_cli.py                       94     94      0      0     0%\ntests/test_web_exceptions.py               277    277     30      0     0%\ntests/test_web_functional.py              1557   1557     24      0     0%\ntests/test_web_log.py                      145    145      4      0     0%\ntests/test_web_middleware.py               245    245      6      0     0%\ntests/test_web_request.py                  544    544      0      0     0%\ntests/test_web_request_handler.py           42     42      0      0     0%\ntests/test_web_response.py                 872    872      6      0     0%\ntests/test_web_runner.py                   179    179      4      0     0%\ntests/test_web_sendfile.py                  85     85      0      0     0%\ntests/test_web_sendfile_functional.py      681    681     18      0     0%\ntests/test_web_server.py                   179    179      0      0     0%\ntests/test_web_urldispatcher.py            511    511     24      0     0%\ntests/test_web_websocket.py                422    422      8      0     0%\ntests/test_web_websocket_functional.py     828    828     24      0     0%\ntests/test_websocket_handshake.py          153    153     12      0     0%\ntests/test_websocket_parser.py             290    290     12      0     0%\ntests/test_websocket_writer.py              96     96      6      0     0%\ntests/test_worker.py                       190    190      2      0     0%\n--------------------------------------------------------------------------\nTOTAL                                    34864  31493   4240     27     9%\n\n============================= slowest 10 durations =============================\n0.04s teardown r2e_tests/test_1.py::test_close_for_threaded_resolver[pyloop]\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_aiodns_not_present[pyloop]\n0.02s teardown r2e_tests/test_1.py::test_async_resolver_error_messages_passed_no_hosts[pyloop]\n0.02s teardown r2e_tests/test_1.py::test_async_resolver_positive_ipv4_lookup[pyloop]\n0.02s call     r2e_tests/test_1.py::test_threaded_negative_lookup_with_unknown_result\n0.02s teardown r2e_tests/test_1.py::test_close_for_async_resolver[pyloop]\n0.02s teardown r2e_tests/test_1.py::test_async_resolver_error_messages_passed[pyloop]\n0.02s teardown r2e_tests/test_1.py::test_async_resolver_ipv6_positive_lookup[pyloop]\n0.02s 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_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_aiodns_not_present[pyloop]\nPASSED r2e_tests/test_1.py::test_aio_dns_is_default\nSKIPPED [1] r2e_tests/test_1.py:357: aiodns <3.2.0 required\nFAILED r2e_tests/test_1.py::test_async_resolver_error_messages_passed[pyloop]\nFAILED r2e_tests/test_1.py::test_async_resolver_error_messages_passed_no_hosts[pyloop]\n=================== 2 failed, 17 passed, 1 skipped in 5.90s ====================\n",
    "old_commit_res_stderr": ""
}
CHANGES/9451.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 Does Not Propagate Error Messages in OSError

**Description:**
When a DNS resolution fails using `AsyncResolver`, the raised `OSError` does not include the original error message from `aiodns`. This omission makes it difficult to understand the specific reason for the failure, hindering effective debugging and error handling.

**Example Code:**
```python
from aiohttp.resolver import AsyncResolver
from unittest.mock import patch
import aiodns
import asyncio

async def test_resolution_error():
    with patch("aiodns.DNSResolver") as mock:
        mock().getaddrinfo.side_effect = aiodns.error.DNSError(1, "Test error message")
        resolver = AsyncResolver()
        await resolver.resolve("x.org")
        # An OSError is raised, but its strerror attribute is None
```

**Expected Behavior:**
When a DNS resolution fails, the `OSError` should include the original error message (e.g., "Test error message") in its `strerror` attribute, providing clear insight into the nature of the failure.

**Actual Behavior:**
The `OSError` raised has its `strerror` attribute set to `None`, resulting in the loss of the original error message. This makes it unclear why the DNS resolution failed.

[/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
from typing import Any, List, 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


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

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

    def __init__(self) -> None:
        self._loop = 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]:
                    # 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, *args: Any, **kwargs: Any) -> None:
        if aiodns is None:
            raise RuntimeError("Resolver requires aiodns library")

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

    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(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]:
                    # 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("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 Does Not Propagate Error Messages in OSError

**Description:**
When a DNS resolution fails using `AsyncResolver`, the raised `OSError` does not include the original error message from `aiodns`. This omission makes it difficult to understand the specific reason for the failure, hindering effective debugging and error handling.

**Example Code:**
```python
from aiohttp.resolver import AsyncResolver
from unittest.mock import patch
import aiodns
import asyncio

async def test_resolution_error():
    with patch("aiodns.DNSResolver") as mock:
        mock().getaddrinfo.side_effect = aiodns.error.DNSError(1, "Test error message")
        resolver = AsyncResolver()
        await resolver.resolve("x.org")
        # An OSError is raised, but its strerror attribute is None
```

**Expected Behavior:**
When a DNS resolution fails, the `OSError` should include the original error message (e.g., "Test error message") in its `strerror` attribute, providing clear insight into the nature of the failure.

**Actual Behavior:**
The `OSError` raised has its `strerror` attribute set to `None`, resulting in the loss of the original error message. This makes it unclear why the DNS resolution failed.

[/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_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_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 daa90b82..1025df06 100644
--- a/aiohttp/resolver.py
+++ b/aiohttp/resolver.py
@@ -100,7 +100,7 @@ class AsyncResolver(AbstractResolver):
             )
         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: List[ResolveResult] = []
         for node in resp.nodes:
             address: Union[Tuple[bytes, int], Tuple[bytes, int, int, int]] = node.addr
@@ -134,7 +134,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\nfrom typing import Any, List, 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\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) -> None:\n        self._loop = 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]:\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__(self, *args: Any, **kwargs: Any) -> None:\n        if aiodns is None:\n            raise RuntimeError(\"Resolver requires aiodns library\")\n\n        self._resolver = aiodns.DNSResolver(*args, **kwargs)\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(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]:\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(\"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 Does Not Propagate Error Messages in OSError

**Description:**
When a DNS resolution fails using `AsyncResolver`, the raised `OSError` does not include the original error message from `aiodns`. This omission makes it difficult to understand the specific reason for the failure, hindering effective debugging and error handling.

**Example Code:**
```python
from aiohttp.resolver import AsyncResolver
from unittest.mock import patch
import aiodns
import asyncio

async def test_resolution_error():
    with patch("aiodns.DNSResolver") as mock:
        mock().getaddrinfo.side_effect = aiodns.error.DNSError(1, "Test error message")
        resolver = AsyncResolver()
        await resolver.resolve("x.org")
        # An OSError is raised, but its strerror attribute is None
```

**Expected Behavior:**
When a DNS resolution fails, the `OSError` should include the original error message (e.g., "Test error message") in its `strerror` attribute, providing clear insight into the nature of the failure.

**Actual Behavior:**
The `OSError` raised has its `strerror` attribute set to `None`, resulting in the loss of the original error message. This makes it unclear why the DNS resolution failed.

[/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
from typing import Any, List, 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


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

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

    def __init__(self) -> None:
        self._loop = 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]:
                    # 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, *args: Any, **kwargs: Any) -> None:
        if aiodns is None:
            raise RuntimeError("Resolver requires aiodns library")

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

    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(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]:
                    # 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("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