commit | eaaaee8c569475614d16e3abf087228673bce9fc | [log] [tgz] |
---|---|---|
author | Yury Selivanov <yselivanov@sprymix.com> | Fri May 20 17:44:19 2016 -0400 |
committer | Yury Selivanov <yselivanov@sprymix.com> | Fri May 20 17:44:19 2016 -0400 |
tree | 8143d7222393206523a7301a4aa611f53428d2d8 | |
parent | 0dad755600d88b48d41b11630dcd1862e3c4ee27 [diff] |
asyncio: Fix getaddrinfo to accept None/str/bytes for 'port' arg Patch by A. Jesse Jiryu Davis.
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index 313cc31..e5e9394 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py
@@ -102,6 +102,11 @@ 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]