]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
asyncio: Support host=b'' for getaddrinfo
authorYury Selivanov <yselivanov@sprymix.com>
Thu, 2 Jun 2016 20:43:52 +0000 (16:43 -0400)
committerYury Selivanov <yselivanov@sprymix.com>
Thu, 2 Jun 2016 20:43:52 +0000 (16:43 -0400)
Lib/asyncio/base_events.py
Lib/test/test_asyncio/test_base_events.py

index ac1089ace498e63baec260b2c9a981e89ed85cb3..e5feb99857463dd18a7ff5f656a1c94e3fff028e 100644 (file)
@@ -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)
index 678ba30e39b440464c73b6adf58d1b9f65820c29..81c35c89c1379bd832115cdcead6578df6da21fd 100644 (file)
@@ -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))