summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/base_events.py
diff options
context:
space:
mode:
authorErwan Le Pape <lepaperwan@users.noreply.github.com>2019-05-17 08:28:39 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-05-17 08:28:39 (GMT)
commitac8eb8f36bf7ca636f8d886eb65a3b532f4725d5 (patch)
treeee22645473384845c6a8911ef3061cdc1fca3766 /Lib/asyncio/base_events.py
parent14514d9084a40f599c57da853a305aa264562a43 (diff)
downloadcpython-ac8eb8f36bf7ca636f8d886eb65a3b532f4725d5.zip
cpython-ac8eb8f36bf7ca636f8d886eb65a3b532f4725d5.tar.gz
cpython-ac8eb8f36bf7ca636f8d886eb65a3b532f4725d5.tar.bz2
bpo-35545: Fix asyncio discarding IPv6 scopes (GH-11271)
This PR proposes a solution to [bpo-35545](https://bugs.python.org/issue35545) by adding an optional `flowinfo` and `scopeid` to `asyncio.base_events._ipaddr_info` to carry the full address information into `_ipaddr_info` and avoid discarding IPv6 specific information. Changelog entry & regression tests to come. https://bugs.python.org/issue35545
Diffstat (limited to 'Lib/asyncio/base_events.py')
-rw-r--r--Lib/asyncio/base_events.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 9613ac2..de9fa4f 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -102,7 +102,7 @@ def _set_reuseport(sock):
'SO_REUSEPORT defined but not implemented.')
-def _ipaddr_info(host, port, family, type, proto):
+def _ipaddr_info(host, port, family, type, proto, flowinfo=0, scopeid=0):
# Try to skip getaddrinfo if "host" is already an IP. Users might have
# handled name resolution in their own code and pass in resolved IPs.
if not hasattr(socket, 'inet_pton'):
@@ -151,7 +151,7 @@ def _ipaddr_info(host, port, family, type, proto):
socket.inet_pton(af, host)
# The host has already been resolved.
if _HAS_IPv6 and af == socket.AF_INET6:
- return af, type, proto, '', (host, port, 0, 0)
+ return af, type, proto, '', (host, port, flowinfo, scopeid)
else:
return af, type, proto, '', (host, port)
except OSError:
@@ -1348,7 +1348,7 @@ class BaseEventLoop(events.AbstractEventLoop):
family=0, type=socket.SOCK_STREAM,
proto=0, flags=0, loop):
host, port = address[:2]
- info = _ipaddr_info(host, port, family, type, proto)
+ info = _ipaddr_info(host, port, family, type, proto, *address[2:])
if info is not None:
# "host" is already a resolved IP.
return [info]