- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
➜
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 | <1545390286.81.0.788709270274.issue35545@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
|---|
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. |
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2018-12-21 11:04:46 | twisteroid ambassador | set | recipients: + twisteroid ambassador, asvetlov, yselivanov, lepaperwan, maxifree |
| 2018-12-21 11:04:46 | twisteroid ambassador | set | messageid: <1545390286.81.0.788709270274.issue35545@psf.upfronthosting.co.za> |
| 2018-12-21 11:04:46 | twisteroid ambassador | link | issue35545 messages |
| 2018-12-21 11:04:46 | twisteroid ambassador | create |
Powered by Roundup Copyright © 1990-2022, Python Software Foundation
Legal Statements
