mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
asyncio: Fix getaddrinfo to accept None/str/bytes for 'port' arg
Patch by A. Jesse Jiryu Davis.
This commit is contained in:
parent
0dad755600
commit
eaaaee8c56
2 changed files with 27 additions and 0 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue