From 3a3671bd49ce6bf330c635bd19a437ee566e6374 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Wed, 23 Sep 2026 18:13:37 +0200 Subject: [PATCH 1/2] gh-157983: Skip test for ctypes.util.find_library when ld is mold (GH-157984) The `mold` linker does not support the `-t` option that `ctypes.util.find_library` uses. Since `find_library` is soft-deprecated and explicitly documented as *not expected to be updated for additional platforms and configurations*, we skip the test in the known failing case. (cherry picked from commit dcaa311d88e0e4fd320f0bcda86db5b277062117) Co-authored-by: Petr Viktorin --- Lib/test/test_ctypes/test_find.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_ctypes/test_find.py b/Lib/test/test_ctypes/test_find.py index 8bc84c3d2ef9f8..92175cc38eecf4 100644 --- a/Lib/test/test_ctypes/test_find.py +++ b/Lib/test/test_ctypes/test_find.py @@ -1,4 +1,5 @@ import os.path +import subprocess import sys import test.support import unittest @@ -78,9 +79,24 @@ def test_shell_injection(self): @unittest.skipUnless(sys.platform.startswith('linux'), 'Test only valid for Linux') class FindLibraryLinux(unittest.TestCase): + @classmethod + def setUpClass(cls): + try: + p = subprocess.run(['ld', '--version'], + stdout=subprocess.PIPE, + stderr=subprocess.DEVNULL, + text=True) + except OSError: + pass + else: + if p.stdout.startswith('mold '): + # The mold linker is known to be incompatible with + # the soft-deprecated ctypes.util.find_library + # (which uses `ld -t`). + raise unittest.SkipTest('Fails when ld is mold') + @thread_unsafe('uses setenv') def test_find_on_libpath(self): - import subprocess import tempfile try: From 7a1dd9440ed0f3e3cf4bdd424795f4a4f380e3b5 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Wed, 23 Sep 2026 18:20:07 +0200 Subject: [PATCH 2/2] Different reasoning for 3.14 --- Lib/test/test_ctypes/test_find.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_ctypes/test_find.py b/Lib/test/test_ctypes/test_find.py index 92175cc38eecf4..9a9c48b6daf839 100644 --- a/Lib/test/test_ctypes/test_find.py +++ b/Lib/test/test_ctypes/test_find.py @@ -91,8 +91,12 @@ def setUpClass(cls): else: if p.stdout.startswith('mold '): # The mold linker is known to be incompatible with - # the soft-deprecated ctypes.util.find_library - # (which uses `ld -t`). + # ctypes.util.find_library. The function is + # documented as "Try to find a library..." + # and formally soft-deprecated in 3.15+. We + # we skip the test rather than try to fix it + # (which would risk breaking other unsupported + # platforms). raise unittest.SkipTest('Fails when ld is mold') @thread_unsafe('uses setenv')