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 Leonardo Mörlein
Recipients Leonardo Mörlein, asvetlov, yselivanov
Date 2019-02-21.19:13:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1550776427.72.0.170763876114.issue36069@roundup.psfhosted.org>
In-reply-to
Content
The tuple (host, port) is ("fe80::5054:01ff:fe04:3402%node4_client", 22) in https://github.com/python/cpython/blob/master/Lib/asyncio/base_events.py#L918. The substring "node4_client" identifies the interface, which is needed for link local connections.

The function self._ensure_resolved() is called and resolves to
infos[0][4] = ("fe80::5054:01ff:fe04:3402", 22, something, 93), where 93 is the resolved scope id (see sin6_scope_id from struct sockaddr_in6 from man ipv6).

Afterwards the self.sock_connect() is called with address = infos[0][4].   In self.sock_connect() the function self._ensure_resolved() is called again. In https://github.com/python/cpython/blob/master/Lib/asyncio/base_events.py#L1282 the scope id is stripped from the tuple. The tuple (host, port) is now only ("fe80::5054:01ff:fe04:3402", 22) and therefore the scope id is lost.

I wrote this quick fix, which is not really suitable as a real solution for the problem:

lemoer@orange ~> diff /usr/lib/python3.7/asyncio/base_events.py{.bak,}
--- /usr/lib/python3.7/asyncio/base_events.py.bak	2019-02-21 18:42:17.060122277 +0100
+++ /usr/lib/python3.7/asyncio/base_events.py	2019-02-21 18:49:36.886866750 +0100
@@ -942,8 +942,8 @@
                             sock = None
                             continue
                     if self._debug:
-                        logger.debug("connect %r to %r", sock, address)
-                    await self.sock_connect(sock, address)
+                        logger.debug("connect %r to %r", sock, (host, port))
+                    await self.sock_connect(sock, (host, port))
                 except OSError as exc:
                     if sock is not None:
                         sock.close()
History
Date User Action Args
2019-02-21 19:13:47Leonardo Mörleinsetrecipients: + Leonardo Mörlein, asvetlov, yselivanov
2019-02-21 19:13:47Leonardo Mörleinsetmessageid: <1550776427.72.0.170763876114.issue36069@roundup.psfhosted.org>
2019-02-21 19:13:47Leonardo Mörleinlinkissue36069 messages
2019-02-21 19:13:47Leonardo Mörleincreate