This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ecatmur2
Recipients asvetlov, ecatmur2, yselivanov
Date 2020-11-13.10:23:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1605263017.45.0.821115077968.issue42342@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-11-13 10:23:37ecatmur2setrecipients: + ecatmur2, asvetlov, yselivanov
2020-11-13 10:23:37ecatmur2setmessageid: <1605263017.45.0.821115077968.issue42342@roundup.psfhosted.org>
2020-11-13 10:23:37ecatmur2linkissue42342 messages
2020-11-13 10:23:34ecatmur2create