Skip to content

Commit 7dbf26b

Browse files
Merge branch 'main' into pyexpat-multibyte-encodings
2 parents fb266e1 + 3cfc249 commit 7dbf26b

3 files changed

Lines changed: 27 additions & 10 deletions

File tree

.github/workflows/mypy.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,11 @@ jobs:
6969
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
7070
with:
7171
persist-credentials: false
72-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
72+
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
7373
with:
7474
python-version: "3.15"
75-
allow-prereleases: true
76-
cache: pip
77-
cache-dependency-path: Tools/requirements-dev.txt
78-
- run: pip install -r Tools/requirements-dev.txt
75+
activate-environment: true
76+
cache-dependency-glob: Tools/requirements-dev.txt
77+
- run: uv pip install -r Tools/requirements-dev.txt
7978
- run: python3 Misc/mypy/make_symlinks.py --symlink
80-
- run: mypy --config-file ${{ matrix.target }}/mypy.ini
79+
- run: mypy --num-workers 4 --config-file ${{ matrix.target }}/mypy.ini

Lib/test/test_socket.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,25 @@ def _have_socket_hyperv():
205205
return True
206206

207207

208+
def _have_udp_lite():
209+
if not hasattr(socket, "IPPROTO_UDPLITE"):
210+
return False
211+
# Older Android versions block UDPLITE with SELinux.
212+
if support.is_android and platform.android_ver().api_level < 29:
213+
return False
214+
215+
try:
216+
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDPLITE)
217+
except OSError as exc:
218+
# Linux 7.1 removed UDP Lite support
219+
if exc.errno == errno.EPROTONOSUPPORT:
220+
return False
221+
raise
222+
sock.close()
223+
224+
return True
225+
226+
208227
@contextlib.contextmanager
209228
def socket_setdefaulttimeout(timeout):
210229
old_timeout = socket.getdefaulttimeout()
@@ -247,10 +266,7 @@ def downgrade_malformed_data_warning():
247266

248267
HAVE_SOCKET_VSOCK = _have_socket_vsock()
249268

250-
# Older Android versions block UDPLITE with SELinux.
251-
HAVE_SOCKET_UDPLITE = (
252-
hasattr(socket, "IPPROTO_UDPLITE")
253-
and not (support.is_android and platform.android_ver().api_level < 29))
269+
HAVE_SOCKET_UDPLITE = _have_udp_lite()
254270

255271
HAVE_SOCKET_BLUETOOTH = _have_socket_bluetooth()
256272

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix test_socket on Linux kernel 7.1 and newer: skip UDP Lite tests if it's
2+
not supported. Patch by Victor Stinner.

0 commit comments

Comments
 (0)