-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
resolver.py/ThreadResolver: address[3] does not exist #5901
Copy link
Copy link
Closed
Labels
bugreproducer: missingThis PR or issue lacks code, which reproduce the problem described or clearly understandable STRThis PR or issue lacks code, which reproduce the problem described or clearly understandable STR
Description
Describe the bug
As outlined at pimutils/vdirsyncer#916, I use python 3.8 with aiohttp 3.8 branch (v3.7.4.post0-209-g22f8be99) . In aiohttp/resolver.py:ThreadedResolver the line
if family == socket.AF_INET6 and address[3]: # type: ignore[misc]
fails, as address has only two elements and address[3] is out of range.
The values of adress are:
AddressFamily.AF_INET ('142.250.185.238', 443)
AddressFamily.AF_INET6 (10, b'\x01\xbb\x00\x00\x00\x00*\x00\x14P@\x01\x08\x13')
The system is not connected to IPv6, no routes, no iPv6 addressese etc, but the kernel understands IPv6. I fixed it locally with:
diff --git a/aiohttp/resolver.py b/aiohttp/resolver.py
index 2161c8fa..4e57b319 100644
--- a/aiohttp/resolver.py
+++ b/aiohttp/resolver.py
@@ -38,16 +38,7 @@ class ThreadedResolver(AbstractResolver):
hosts = []
for family, _, proto, _, address in infos:
- if family == socket.AF_INET6 and address[3]: # type: ignore[misc]
- # 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.
- host, _port = socket.getnameinfo(
- address, socket.NI_NUMERICHOST | socket.NI_NUMERICSERV
- )
- port = int(_port)
- else:
- host, port = address[:2]
+ host, port = address[:2]
hosts.append(
{
"hostname": hostname,To Reproduce
See above.
Expected behavior
Shall not read address[3], when address[3] does not exist.
Logs/tracebacks
Not applicable.Python Version
$ python --version
Python 3.8.8+aiohttp Version
$ python -m pip show aiohttp
3.8.0a0multidict Version
$ python -m pip show multidict
5.1.0yarl Version
$ python -m pip show yarl
1.6.3OS
Linux from Scratch, python 3.8.8+
Related component
Client
Additional context
No response
Code of Conduct
- I agree to follow the aio-libs Code of Conduct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugreproducer: missingThis PR or issue lacks code, which reproduce the problem described or clearly understandable STRThis PR or issue lacks code, which reproduce the problem described or clearly understandable STR