FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.10] gh-149776: Skip UDP Lite tests if it's not supported (#149777) by vstinner · Pull Request #153594 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
21 changes: 20 additions & 1 deletion Lib/test/test_socket.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,25 @@ def _have_socket_bluetooth():
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 All @@ -166,7 +185,7 @@ def socket_setdefaulttimeout(timeout):

HAVE_SOCKET_VSOCK = _have_socket_vsock()

HAVE_SOCKET_UDPLITE = hasattr(socket, "IPPROTO_UDPLITE")
HAVE_SOCKET_UDPLITE = _have_udp_lite()

HAVE_SOCKET_BLUETOOTH = _have_socket_bluetooth()

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL