Skip to content

Tuple index out of range with 3.7.1 and no IPv6 #5156

Closed
@danielnelson

Description

🐞 Describe the bug
After upgrading to aiohttp==3.7.1, dns resolution fails with an exception.

💡 To Reproduce

  1. I believe this is due to not have IPV6 enabled in my kernel, which is custom compiled with.
    CONFIG_IPV6=n
  2. Run:
    import asyncio
    import aiohttp
    
    
    async def main():
        async with aiohttp.ClientSession() as session:
            async with session.get('http://python.org') as response:
                print(response.status)
    
    
    asyncio.run(main())
  3. Actual behavior
    $ python bug.py
    Traceback (most recent call last):
      File "bug.py", line 11, in <module>
        asyncio.run(main())
      File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
        return loop.run_until_complete(main)
      File "/usr/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
        return future.result()
      File "bug.py", line 7, in main
        async with session.get('http://python.org') as response:
      File "/home/dbn/usr/py37/lib/python3.7/site-packages/aiohttp/client.py", line 1124, in __aenter__
        self._resp = await self._coro
      File "/home/dbn/usr/py37/lib/python3.7/site-packages/aiohttp/client.py", line 528, in _request
        req, traces=traces, timeout=real_timeout
      File "/home/dbn/usr/py37/lib/python3.7/site-packages/aiohttp/connector.py", line 541, in connect
        proto = await self._create_connection(req, traces, timeout)
      File "/home/dbn/usr/py37/lib/python3.7/site-packages/aiohttp/connector.py", line 898, in _create_connection
        _, proto = await self._create_direct_connection(req, traces, timeout)
      File "/home/dbn/usr/py37/lib/python3.7/site-packages/aiohttp/connector.py", line 1005, in _create_direct_connection
        hosts = await asyncio.shield(host_resolved)
      File "/home/dbn/usr/py37/lib/python3.7/site-packages/aiohttp/connector.py", line 871, in _resolve_host
        addrs = await self._resolver.resolve(host, port, family=self._family)
      File "/home/dbn/usr/py37/lib/python3.7/site-packages/aiohttp/resolver.py", line 37, in resolve
        if family == socket.AF_INET6 and address[3]:  # type: ignore
    IndexError: tuple index out of range

💡 Expected behavior

Should print 200.

📋 Logs/tracebacks

📋 Your version of the Python

$ python --version
Python 3.7.9

📋 Your version of the aiohttp/yarl/multidict distributions

$ python -m pip show aiohttp
Name: aiohttp
Version: 3.7.1
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author: Nikolay Kim
Author-email: fafhrd91@gmail.com
License: Apache 2
Location: /home/dbn/usr/py37/lib/python3.7/site-packages
Requires: multidict, async-timeout, typing-extensions, yarl, chardet, attrs
Required-by: replay-proxy
$ python -m pip show multidict
Name: multidict
Version: 4.7.6
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache 2
Location: /home/dbn/usr/py37/lib/python3.7/site-packages
Requires:
Required-by: yarl, aiohttp
$ python -m pip show yarl
Name: yarl
Version: 1.5.1
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl/
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache 2
Location: /home/dbn/usr/py37/lib/python3.7/site-packages
Requires: typing-extensions, multidict, idna
Required-by: aiohttp, replay-proxy

📋 Additional context

Metadata

Assignees

No one assigned

    Labels

    bugneed pull requestregressionSomething that used to work stopped working "as before" after upgradereproducer: presentThis PR or issue contains code, which reproduce the problem described or clearly understandable STR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions