Skip UDP Lite tests if it's not supported

- Fixes FTBFS on Linux kernel 7.1 and newer
This commit is contained in:
Miro Hrončok 2026-07-28 11:41:07 +02:00
commit 223df02052
2 changed files with 75 additions and 1 deletions

View file

@ -0,0 +1,63 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Victor Stinner <vstinner@python.org>
Date: Wed, 13 May 2026 17:27:56 +0200
Subject: 00491: gh-149776: Skip UDP Lite tests if it's not supported
Fix test_socket on Linux kernel 7.1 and newer: skip UDP Lite tests if
it's not supported.
(cherry picked from commit 3cfc249e11a132dc69624150843779aa96c72b2b)
(cherry picked from commit 49d08674d8dba50dc29539e3c7bce21d66066b06)
---
Lib/test/test_socket.py | 21 ++++++++++++++++++-
...-05-13-14-53-23.gh-issue-149776.orqgsn.rst | 2 ++
2 files changed, 22 insertions(+), 1 deletion(-)
create mode 100644 Misc/NEWS.d/next/Tests/2026-05-13-14-53-23.gh-issue-149776.orqgsn.rst
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index f200fc9792..9453a2c7e8 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -157,6 +157,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()
@@ -181,7 +200,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()
diff --git a/Misc/NEWS.d/next/Tests/2026-05-13-14-53-23.gh-issue-149776.orqgsn.rst b/Misc/NEWS.d/next/Tests/2026-05-13-14-53-23.gh-issue-149776.orqgsn.rst
new file mode 100644
index 0000000000..e86a9130ff
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2026-05-13-14-53-23.gh-issue-149776.orqgsn.rst
@@ -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.

View file

@ -17,7 +17,7 @@ URL: https://www.python.org/
#global prerel ...
%global upstream_version %{general_version}%{?prerel}
Version: %{general_version}%{?prerel:~%{prerel}}
Release: 4%{?dist}
Release: 5%{?dist}
License: Python-2.0.1
@ -475,6 +475,13 @@ Patch484: 00484-cve-2026-3644.patch
# Stack overflow parsing XML with deeply nested DTD content models
Patch485: 00485-cve-2026-4224.patch
# 00491 # 1ad95144c42a6933283352245c5df5a4c142e75f
# gh-149776: Skip UDP Lite tests if it's not supported
#
# Fix test_socket on Linux kernel 7.1 and newer: skip UDP Lite tests if
# it's not supported.
Patch491: 00491-gh-149776-skip-udp-lite-tests-if-it-s-not-supported.patch
# (New patches go here ^^^)
#
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
@ -1811,6 +1818,10 @@ CheckPython optimized
# ======================================================
%changelog
* Tue Jul 28 2026 Miro Hrončok <mhroncok@redhat.com> - 3.12.13-5
- Skip UDP Lite tests if it's not supported
- Fixes FTBFS on Linux kernel 7.1 and newer
* Thu Jul 16 2026 Fedora Release Engineering <releng@fedoraproject.org> - 3.12.13-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild