Context: CentOS 7.8.2003, Python 3.8 from SCL. localhost has IPv4 and IPv6 bindings, IPv6 first: $ python -c "import socket;print(socket.getaddrinfo('localhost',0,type=socket.SOCK_STREAM))" [(<AddressFamily.AF_INET6: 10>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('::1', 0, 0, 0)), (<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('127.0.0.1', 0))] import asyncio async def main(): await asyncio.open_connection('localhost', 9990, local_addr=('localhost', 9991)) asyncio.run(main()) Traceback (most recent call last): File "async.py", line 4, in <module> asyncio.run(main()) File "/opt/rh/rh-python38/root/usr/lib64/python3.8/asyncio/runners.py", line 43, in run return loop.run_until_complete(main) File "/opt/rh/rh-python38/root/usr/lib64/python3.8/asyncio/base_events.py", line 608, in run_until_complete return future.result() File "async.py", line 3, in main await asyncio.open_connection('10.10.10.10', 9990, local_addr=('localhost', 9991)) File "/opt/rh/rh-python38/root/usr/lib64/python3.8/asyncio/streams.py", line 52, in open_connection transport, _ = await loop.create_connection( File "/opt/rh/rh-python38/root/usr/lib64/python3.8/asyncio/base_events.py", line 1002, in create_connection sock = await self._connect_sock( File "/opt/rh/rh-python38/root/usr/lib64/python3.8/asyncio/base_events.py", line 904, in _connect_sock sock.bind(laddr) TypeError: AF_INET address must be a pair (host, port) It looks like this has a similar root cause to issue 35302 - we should be filtering local addrinfos by family for valid combinations. |