twisteroid ambassador <[email protected]> added the comment:
I think the root cause of this bug is a bit of confusion.
The "customer-facing" asyncio API, create_connection(), takes two arguments:
host and port. The lower-level API that actually deal with connecting sockets,
socket.connect() and loop.sock_connect(), takes one argument: the address
tuple. These are *not the same thing*, despite an IPv4 address tuple having two
elements (host, port), and must not be mixed.
_ensure_resolved() is the function responsible for turning host + port into an
address tuple, and it does the right thing, turning
host="fe80::1%lo",port=12345 into ('fe80::1', 12345, 0, 1) correctly. The
mistake is taking the address tuple and passing it through _ensure_resolved()
again, since that's not the correct input type for it: the only correct input
type is host + port.
So I think the appropriate fix for this bug is to make sure _ensure_resolved is
only called once. In particular, BaseSelectorEventLoop.sock_connect()
https://github.com/python/cpython/blob/3bc0ebab17bf5a2c29d2214743c82034f82e6573/Lib/asyncio/selector_events.py#L458
should not call _ensure_resolved(). It might be a good idea to add some
comments clarifying that sock_connect() takes an address tuple argument, not
host + port, and likewise for sock_connect() on each event loop implementation.
----------
nosy: +twisteroid ambassador
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35545>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com