Skip to content

Commit

Permalink
_socket.py: fix for systems where AI_NUMERICSERV is not defined
Browse files Browse the repository at this point in the history
Credits to @CoolCat467
Closes: python-trio#3133
  • Loading branch information
barracuda156 committed Nov 17, 2024
1 parent 6cacb3b commit 5260922
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/trio/_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ def set_custom_socket_factory(
# getaddrinfo and friends
################################################################

_NUMERIC_ONLY = _stdlib_socket.AI_NUMERICHOST | _stdlib_socket.AI_NUMERICSERV
# AI_NUMERICSERV may be missing on some older platforms, so use it when available.
_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
Expand Down

0 comments on commit 5260922

Please sign in to comment.