From 46c922220c875befac414636187baf84e9a8ca70 Mon Sep 17 00:00:00 2001 From: Vioshim Date: Mon, 2 Nov 2026 16:36:00 -0500 Subject: [PATCH] fix: enhance address family check in __loop_create_datagram_endpoint --- python/rsloop/_loop_compat.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/python/rsloop/_loop_compat.py b/python/rsloop/_loop_compat.py index 109b73c..01c77cf 100644 --- a/python/rsloop/_loop_compat.py +++ b/python/rsloop/_loop_compat.py @@ -567,11 +567,15 @@ async def __loop_create_datagram_endpoint( raise ValueError( "socket modifier keyword arguments can not be used when sock is specified" ) - if sock is None and local_addr is None and remote_addr is None: + if ( + sock is None + and local_addr is None + and remote_addr is None + and family == 0 + ): raise ValueError("unexpected address family") if sock is None: - addrinfos = None if remote_addr is not None: addrinfos = await self.getaddrinfo( *remote_addr, @@ -588,6 +592,10 @@ async def __loop_create_datagram_endpoint( proto=proto, flags=flags, ) + else: + addrinfos = [ + (family, __socket.SOCK_DGRAM, proto, "", None), + ] if not addrinfos: raise OSError("getaddrinfo() returned empty list")