From 4aa9b394380b6b25b1b7c66ad16d84a5fce46d7c Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Thu, 24 Sep 2026 02:33:53 -0700 Subject: [PATCH] [3.13] gh-157983: Skip test for ctypes.util.find_library when ld is mold (GH-157984) (GH-158009) (cherry picked from commit 1b42680b3a370e8466d3b8ea17ca598e98066b88) Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Co-authored-by: Petr Viktorin --- Lib/test/test_ctypes/test_find.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_ctypes/test_find.py b/Lib/test/test_ctypes/test_find.py index 85b28617d2d7549..433d52079379723 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,8 +79,27 @@ 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 + # 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') + def test_find_on_libpath(self): - import subprocess import tempfile try: