summaryrefslogtreecommitdiff
path: root/Lib/asyncio/base_events.py
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2016-05-20 17:44:19 -0400
committerYury Selivanov <yselivanov@sprymix.com>2016-05-20 17:44:19 -0400
commiteaaaee8c569475614d16e3abf087228673bce9fc (patch)
tree8143d7222393206523a7301a4aa611f53428d2d8 /Lib/asyncio/base_events.py
parent0dad755600d88b48d41b11630dcd1862e3c4ee27 (diff)
downloadcpython-git-eaaaee8c569475614d16e3abf087228673bce9fc.tar.gz
asyncio: Fix getaddrinfo to accept None/str/bytes for 'port' arg
Patch by A. Jesse Jiryu Davis.
Diffstat (limited to 'Lib/asyncio/base_events.py')
-rw-r--r--Lib/asyncio/base_events.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 313cc316e5..e5e9394835 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -102,6 +102,11 @@ def _ipaddr_info(host, port, family, type, proto):
else:
return None
+ if port in {None, ''}:
+ port = 0
+ elif isinstance(port, (bytes, str)):
+ port = int(port)
+
if hasattr(socket, 'inet_pton'):
if family == socket.AF_UNSPEC:
afs = [socket.AF_INET, socket.AF_INET6]