Skip to content

Commit 3f7b30e

Browse files
committed
_socket.py: fix for systems where AI_NUMERICSERV is not defined
Credits to @CoolCat467 Closes: #3133
1 parent 71e4ab0 commit 3f7b30e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/trio/_socket.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ def set_custom_socket_factory(
164164
# getaddrinfo and friends
165165
################################################################
166166

167-
_NUMERIC_ONLY = _stdlib_socket.AI_NUMERICHOST | _stdlib_socket.AI_NUMERICSERV
167+
# AI_NUMERICSERV may be missing on some older platforms, so use it when available.
168+
# See: https://github.com/python-trio/trio/issues/3133
169+
_NUMERIC_ONLY = _stdlib_socket.AI_NUMERICHOST
170+
_NUMERIC_ONLY |= getattr(_stdlib_socket, "AI_NUMERICSERV", 0)
168171

169172

170173
# It would be possible to @overload the return value depending on Literal[AddressFamily.INET/6], but should probably be added in typeshed first

0 commit comments

Comments
 (0)