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