From: Yury Selivanov Date: Thu, 2 Jun 2016 20:43:52 +0000 (-0400) Subject: asyncio: Support host=b'' for getaddrinfo X-Git-Tag: v3.5.2rc1~81 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a8f895f051588cc5186650f13118b0149ae7e3d5;p=thirdparty%2FPython%2Fcpython.git asyncio: Support host=b'' for getaddrinfo --- diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index ac1089ace498..e5feb9985746 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -102,7 +102,7 @@ def _ipaddr_info(host, port, family, type, proto): else: return None - if port in {None, ''}: + if port in {None, '', b''}: port = 0 elif isinstance(port, (bytes, str)): port = int(port) diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py index 678ba30e39b4..81c35c89c137 100644 --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -130,6 +130,10 @@ class BaseEventTests(test_utils.TestCase): (INET, STREAM, TCP, '', ('1.2.3.4', 0)), base_events._ipaddr_info('1.2.3.4', None, INET, STREAM, TCP)) + self.assertEqual( + (INET, STREAM, TCP, '', ('1.2.3.4', 0)), + base_events._ipaddr_info('1.2.3.4', b'', INET, STREAM, TCP)) + self.assertEqual( (INET, STREAM, TCP, '', ('1.2.3.4', 0)), base_events._ipaddr_info('1.2.3.4', '', INET, STREAM, TCP))