bpo-35545: Fix asyncio discarding IPv6 scopes (GH-11271) · python/cpython@ac8eb8f (original) (raw)

`@@ -102,7 +102,7 @@ def _set_reuseport(sock):

`

102

102

`'SO_REUSEPORT defined but not implemented.')

`

103

103

``

104

104

``

105

``

`-

def _ipaddr_info(host, port, family, type, proto):

`

``

105

`+

def _ipaddr_info(host, port, family, type, proto, flowinfo=0, scopeid=0):

`

106

106

`# Try to skip getaddrinfo if "host" is already an IP. Users might have

`

107

107

`# handled name resolution in their own code and pass in resolved IPs.

`

108

108

`if not hasattr(socket, 'inet_pton'):

`

`@@ -151,7 +151,7 @@ def _ipaddr_info(host, port, family, type, proto):

`

151

151

`socket.inet_pton(af, host)

`

152

152

`# The host has already been resolved.

`

153

153

`if _HAS_IPv6 and af == socket.AF_INET6:

`

154

``

`-

return af, type, proto, '', (host, port, 0, 0)

`

``

154

`+

return af, type, proto, '', (host, port, flowinfo, scopeid)

`

155

155

`else:

`

156

156

`return af, type, proto, '', (host, port)

`

157

157

`except OSError:

`

`@@ -1348,7 +1348,7 @@ async def _ensure_resolved(self, address, *,

`

1348

1348

`family=0, type=socket.SOCK_STREAM,

`

1349

1349

`proto=0, flags=0, loop):

`

1350

1350

`host, port = address[:2]

`

1351

``

`-

info = _ipaddr_info(host, port, family, type, proto)

`

``

1351

`+

info = _ipaddr_info(host, port, family, type, proto, *address[2:])

`

1352

1352

`if info is not None:

`

1353

1353

`# "host" is already a resolved IP.

`

1354

1354

`return [info]

`