Skip to content

Commit 72b49bb

Browse files
author
Elliot Cameron
committed
Fix socket tests on older Linux kernels
Ran into this trying to run the tests on RHEL8.
1 parent 578efcb commit 72b49bb

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/trio/_tests/test_socket.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,18 @@ def setsockopt_tests(sock: SocketType | SocketStream) -> None:
470470
try:
471471
sock.setsockopt(tsocket.SOL_SOCKET, tsocket.SO_BINDTODEVICE, None, 0)
472472
except OSError as e:
473-
# some versions of Python have the attribute yet can run on platforms
474-
# that do not support it. For instance, MacOS 15 gained support for
475-
# SO_BINDTODEVICE and CPython 3.13.1 was built on it (presumably), but
476-
# our CI runners ran MacOS 14 and so failed.
477-
assert e.errno == 42 # noqa: PT017
473+
assert e.errno in [ # noqa: PT017
474+
# some versions of Python have the attribute yet can run on
475+
# platforms that do not support it. For instance, MacOS 15
476+
# gained support for SO_BINDTODEVICE and CPython 3.13.1 was
477+
# built on it (presumably), but our CI runners ran MacOS 14 and
478+
# so failed.
479+
42,
480+
# Older Linux kernels (prior to patch
481+
# https://lore.kernel.org/netdev/[email protected]/t/)
482+
# do not support SO_BINDTODEVICE as an unprivileged user.
483+
errno.EPERM,
484+
]
478485

479486
# specifying value
480487
sock.setsockopt(tsocket.IPPROTO_TCP, tsocket.TCP_NODELAY, False)

0 commit comments

Comments
 (0)