Skip to content

Commit

Permalink
bpo-27929: resolve names only for AF_INET/AF_INET6 with asyncio (pyth…
Browse files Browse the repository at this point in the history
…onGH-32131)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
  • Loading branch information
vincentbernat and asvetlov committed Mar 28, 2022
1 parent 7b44ade commit 5c30388
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Lib/asyncio/selector_events.py
Expand Up @@ -620,7 +620,8 @@ async def sock_connect(self, sock, address):
if self._debug and sock.gettimeout() != 0:
raise ValueError("the socket must be non-blocking")

if not hasattr(socket, 'AF_UNIX') or sock.family != socket.AF_UNIX:
if sock.family == socket.AF_INET or (
base_events._HAS_IPv6 and sock.family == socket.AF_INET6):
resolved = await self._ensure_resolved(
address, family=sock.family, type=sock.type, proto=sock.proto,
loop=self,
Expand Down
@@ -0,0 +1,3 @@
Fix :meth:`asyncio.loop.sock_connect` to only resolve names for :const:`socket.AF_INET` or
:const:`socket.AF_INET6` families. Resolution may not make sense for other families,
like :const:`socket.AF_BLUETOOTH` and :const:`socket.AF_UNIX`.

0 comments on commit 5c30388

Please sign in to comment.