bpo-35545: Fix mishandling of scoped IPv6 addresses by twisteroidambassador · Pull Request #11403 · python/cpython (original) (raw)
Most likely this PR is not needed anymore.
This PR is associated with 2 issues, bpo-33678 and bpo-35545. bpo-35545 has two PRs, and that issue has been fixed with the other PR #11271 that got merged.
(That PR went in a completely different direction from this one. The root cause of bpo-35545 is that, when a pre-resolved link-local IPv6 addresses pass through _ensure_resolved() again, information is lost. My idea is to make sure an address never passes through _ensure_resolved() more than once. I still think this is the cleaner approach, but it is a breaking change, because it means sock_connect() no longer accepts all (host, port), but must take a pre-resolved address. #11271 instead made sure that _ensure_resolved() does not lose information, so it fixed the issue in a backward-compatible way.)
bpo-33678 is not fixed yet. This PR would fix it as a side effect, but since we already went with #11271 for bpo-35545, I don't think we should merge this one just for bpo-33678. Instead, I think bpo-33678 can be fixed in a minimally-intrusive way as suggested by the first comment there, basically changing this line:
resolved = await self._ensure_resolved( |
---|
address, family=sock.family, proto=sock.proto, loop=self) |
To:
resolved = await self._ensure_resolved(
address, family=sock.family, type=sock.type, proto=sock.proto, loop=self)