From b76db238697a3fc7beb9b8a602125183560a7055 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Tue, 12 Nov 2024 14:05:10 +0800 Subject: [PATCH] _socket.py: fix for systems where AI_NUMERICSERV is not defined Credits to @CoolCat467 Closes: https://github.com/python-trio/trio/issues/3133 --- src/trio/_socket.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/trio/_socket.py b/src/trio/_socket.py index ce57aab9c..6f8950d99 100644 --- a/src/trio/_socket.py +++ b/src/trio/_socket.py @@ -169,7 +169,8 @@ def set_custom_socket_factory( # getaddrinfo and friends ################################################################ -_NUMERIC_ONLY = _stdlib_socket.AI_NUMERICHOST | _stdlib_socket.AI_NUMERICSERV +_NUMERIC_ONLY = _stdlib_socket.AI_NUMERICHOST +_NUMERIC_ONLY |= getattr(_stdlib_socket, "AI_NUMERICSERV", 0) # It would be possible to @overload the return value depending on Literal[AddressFamily.INET/6], but should probably be added in typeshed first