Skip to content

Commit 2bcbc31

Browse files
bpo-27929: resolve names only for AF_INET/AF_INET6 with asyncio (GH-32131)
Co-authored-by: Andrew Svetlov <[email protected]> (cherry picked from commit 5c30388) Co-authored-by: Vincent Bernat <[email protected]>
1 parent 5944807 commit 2bcbc31

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Lib/asyncio/selector_events.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ async def sock_connect(self, sock, address):
487487
if self._debug and sock.gettimeout() != 0:
488488
raise ValueError("the socket must be non-blocking")
489489

490-
if not hasattr(socket, 'AF_UNIX') or sock.family != socket.AF_UNIX:
490+
if sock.family == socket.AF_INET or (
491+
base_events._HAS_IPv6 and sock.family == socket.AF_INET6):
491492
resolved = await self._ensure_resolved(
492493
address, family=sock.family, type=sock.type, proto=sock.proto,
493494
loop=self,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix :meth:`asyncio.loop.sock_connect` to only resolve names for :const:`socket.AF_INET` or
2+
:const:`socket.AF_INET6` families. Resolution may not make sense for other families,
3+
like :const:`socket.AF_BLUETOOTH` and :const:`socket.AF_UNIX`.

0 commit comments

Comments
 (0)