Skip to content

Commit

Permalink
Merge pull request #3219 from de11n/old-linux-kernel-test-support
Browse files Browse the repository at this point in the history
Fix socket tests on older Linux kernels
  • Loading branch information
jakkdl authored Mar 6, 2025
2 parents 578efcb + 72b49bb commit 1274a23
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/trio/_tests/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,18 @@ def setsockopt_tests(sock: SocketType | SocketStream) -> None:
try:
sock.setsockopt(tsocket.SOL_SOCKET, tsocket.SO_BINDTODEVICE, None, 0)
except OSError as e:
# some versions of Python have the attribute yet can run on platforms
# that do not support it. For instance, MacOS 15 gained support for
# SO_BINDTODEVICE and CPython 3.13.1 was built on it (presumably), but
# our CI runners ran MacOS 14 and so failed.
assert e.errno == 42 # noqa: PT017
assert e.errno in [ # noqa: PT017
# some versions of Python have the attribute yet can run on
# platforms that do not support it. For instance, MacOS 15
# gained support for SO_BINDTODEVICE and CPython 3.13.1 was
# built on it (presumably), but our CI runners ran MacOS 14 and
# so failed.
42,
# Older Linux kernels (prior to patch
# https://lore.kernel.org/netdev/m37drhs1jn.fsf@bernat.ch/t/)
# do not support SO_BINDTODEVICE as an unprivileged user.
errno.EPERM,
]

# specifying value
sock.setsockopt(tsocket.IPPROTO_TCP, tsocket.TCP_NODELAY, False)
Expand Down

0 comments on commit 1274a23

Please sign in to comment.