Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions Lib/test/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,25 @@ def _have_socket_hyperv():
return True


def _have_udp_lite():
if not hasattr(socket, "IPPROTO_UDPLITE"):
return False
# Older Android versions block UDPLITE with SELinux.
if support.is_android and platform.android_ver().api_level < 29:
return False

try:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDPLITE)
except OSError as exc:
# Linux 7.1 removed UDP Lite support
if exc.errno == errno.EPROTONOSUPPORT:
return False
raise
sock.close()

return True


@contextlib.contextmanager
def socket_setdefaulttimeout(timeout):
old_timeout = socket.getdefaulttimeout()
Expand Down Expand Up @@ -247,10 +266,7 @@ def downgrade_malformed_data_warning():

HAVE_SOCKET_VSOCK = _have_socket_vsock()

# Older Android versions block UDPLITE with SELinux.
HAVE_SOCKET_UDPLITE = (
hasattr(socket, "IPPROTO_UDPLITE")
and not (support.is_android and platform.android_ver().api_level < 29))
HAVE_SOCKET_UDPLITE = _have_udp_lite()

HAVE_SOCKET_BLUETOOTH = _have_socket_bluetooth()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix test_socket on Linux kernel 7.1 and newer: skip UDP Lite tests if it's
not supported. Patch by Victor Stinner.
Loading