Skip to content

Commit b591c95

Browse files
hugovkencukou
andauthored
[3.11] gh-157983: Skip test for ctypes.util.find_library when ld is mold (GH-157984) (GH-158066)
(cherry picked from commit 1b42680) Co-authored-by: Petr Viktorin <encukou@gmail.com>
1 parent 9eaf48a commit b591c95

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

‎Lib/ctypes/test/test_find.py‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import unittest
22
import unittest.mock
33
import os.path
4+
import subprocess
45
import sys
56
import test.support
67
from test.support import os_helper
@@ -75,8 +76,27 @@ def test_shell_injection(self):
7576
@unittest.skipUnless(sys.platform.startswith('linux'),
7677
'Test only valid for Linux')
7778
class FindLibraryLinux(unittest.TestCase):
79+
@classmethod
80+
def setUpClass(cls):
81+
try:
82+
p = subprocess.run(['ld', '--version'],
83+
stdout=subprocess.PIPE,
84+
stderr=subprocess.DEVNULL,
85+
text=True)
86+
except OSError:
87+
pass
88+
else:
89+
if p.stdout.startswith('mold '):
90+
# The mold linker is known to be incompatible with
91+
# ctypes.util.find_library. The function is
92+
# documented as "Try to find a library..."
93+
# and formally soft-deprecated in 3.15+. We
94+
# we skip the test rather than try to fix it
95+
# (which would risk breaking other unsupported
96+
# platforms).
97+
raise unittest.SkipTest('Fails when ld is mold')
98+
7899
def test_find_on_libpath(self):
79-
import subprocess
80100
import tempfile
81101

82102
try:

0 commit comments

Comments
 (0)