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))