[issue33678] selector_events.BaseSelectorEventLoop.sock_connect should preserve socket type
Gus Goulart
report at bugs.python.org
Tue Nov 6 19:33:30 EST 2018
Gus Goulart <augusto at goulart.me> added the comment:
This error seems to come from base_events.py, lines 142-145, and since it's an OS specific limitation, I can't see Sebastien's suggestion as a feasible solution.
Maybe we could come up with something along the lines of the following patch. What do you think about it?
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 3726c556d4..15ee4d9d1b 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -142,6 +142,9 @@ def _ipaddr_info(host, port, family, type, proto):
if '%' in host:
# Linux's inet_pton doesn't accept an IPv6 zone index after host,
# like '::1%lo0'.
+ if sys.platform.startswith('linux'):
+ return OSError("Linux's inet_pton doesn't accept an IPv6 "
+ "zone index after host")
return None
for af in afs:
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
index 6d544d1eda..1b944ff89e 100644
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -109,6 +109,9 @@ class BaseEventTests(test_utils.TestCase):
self.assertIsNone(
base_events._ipaddr_info('::3', 1, INET, STREAM, TCP))
+ @unittest.skipIf(sys.platform.startswith('linux'),
+ "Linux's inet_pton doesn't accept an IPv6 zone index after host")
+ def test_for(self):
# IPv6 address with zone index.
self.assertIsNone(
base_events._ipaddr_info('::3%lo0', 1, INET6, STREAM, TCP))
----------
keywords: +patch
nosy: +gus.goulart, taleinat
Added file: https://bugs.python.org/file47913/issue33678.patch
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33678>
_______________________________________
More information about the Python-bugs-list
mailing list