summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2016-06-02 20:43:52 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2016-06-02 20:43:52 (GMT)
commita8f895f051588cc5186650f13118b0149ae7e3d5 (patch)
tree907d0a08cd880cddb722201fd2d2c3e4c57e8f60 /Lib
parent6a8e626a60baef76b03df81a0b087dc9fdc3efcf (diff)
downloadcpython-a8f895f051588cc5186650f13118b0149ae7e3d5.zip
cpython-a8f895f051588cc5186650f13118b0149ae7e3d5.tar.gz
cpython-a8f895f051588cc5186650f13118b0149ae7e3d5.tar.bz2
asyncio: Support host=b'' for getaddrinfo
Diffstat (limited to 'Lib')
-rw-r--r--Lib/asyncio/base_events.py2
-rw-r--r--Lib/test/test_asyncio/test_base_events.py4
2 files changed, 5 insertions, 1 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index ac1089a..e5feb99 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 678ba30..81c35c8 100644
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -132,6 +132,10 @@ class BaseEventTests(test_utils.TestCase):
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))
self.assertEqual(