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 twisteroid ambassador
Recipients asvetlov, lepaperwan, maxifree, twisteroid ambassador, yselivanov
Date 2018-12-21.11:04:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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() 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.
Date User Action Args
2018-12-21 11:04:46twisteroid ambassadorsetrecipients: + twisteroid ambassador, asvetlov, yselivanov, lepaperwan, maxifree
2018-12-21 11:04:46twisteroid ambassadorsetmessageid: <>
2018-12-21 11:04:46twisteroid ambassadorlinkissue35545 messages
2018-12-21 11:04:46twisteroid ambassadorcreate