]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-141600: Fix musl version detection on Void Linux (GH-141850)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 22 Nov 2025 18:47:47 +0000 (19:47 +0100)
committerGitHub <noreply@github.com>
Sat, 22 Nov 2025 18:47:47 +0000 (18:47 +0000)
(cherry picked from commit 08477dbf300020cc67006c180917c02ee8a5cec8)

Co-authored-by: Andrew J. Hesford <ajh@sideband.org>
Lib/platform.py
Lib/test/test_platform.py
Lib/test/test_support.py
Misc/NEWS.d/next/Library/2025-11-15-14-58-12.gh-issue-141600.XY2BXg.rst [new file with mode: 0644]

index 784b6b749b75245f8fe5de5eee25674071aa0c07..b017b841311be3e40481c34bdf56c4eb0195d210 100644 (file)
@@ -199,7 +199,7 @@ def libc_ver(executable=None, lib='', version='', chunksize=16384):
         | (GLIBC_([0-9.]+))
         | (libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)
         | (musl-([0-9.]+))
-        | (libc.musl(?:-\w+)?.so(?:\.(\d[0-9.]*))?)
+        | ((?:libc\.|ld-)musl(?:-\w+)?.so(?:\.(\d[0-9.]*))?)
         """,
         re.ASCII | re.VERBOSE)
 
@@ -238,7 +238,7 @@ def libc_ver(executable=None, lib='', version='', chunksize=16384):
                 elif V(glibcversion) > V(ver):
                     ver = glibcversion
             elif so:
-                if lib != 'glibc':
+                if lib not in ('glibc', 'musl'):
                     lib = 'libc'
                     if soversion and (not ver or V(soversion) > V(ver)):
                         ver = soversion
index 187a3d548091057c458d48bac2edf9d22e8d3490..e879e48571f3f7033619704fbf8cfa018fe57e72 100644 (file)
@@ -562,6 +562,8 @@ class PlatformTest(unittest.TestCase):
                 (b'/aports/main/musl/src/musl-1.2.5.7', ('musl', '1.2.5.7')),
                 (b'libc.musl.so.1', ('musl', '1')),
                 (b'libc.musl-x86_64.so.1.2.5', ('musl', '1.2.5')),
+                (b'ld-musl.so.1', ('musl', '1')),
+                (b'ld-musl-x86_64.so.1.2.5', ('musl', '1.2.5')),
                 (b'', ('', '')),
             ):
                 with open(filename, 'wb') as fp:
@@ -584,6 +586,10 @@ class PlatformTest(unittest.TestCase):
                     b'libc.musl-x86_64.so.1.4.1\0libc.musl-x86_64.so.2.1.1\0libc.musl-x86_64.so.2.0.1',
                     ('musl', '2.1.1'),
                 ),
+                (
+                    b'ld-musl-x86_64.so.1.4.1\0ld-musl-x86_64.so.2.1.1\0ld-musl-x86_64.so.2.0.1',
+                    ('musl', '2.1.1'),
+                ),
                 (b'no match here, so defaults are used', ('test', '100.1.0')),
             ):
             with open(filename, 'wb') as f:
index e8d5e0d72e79c816db8f949bb40e267a8c32d4ee..dba1dbf2c5a8e659ea2b9ca64ee286205a065ca8 100644 (file)
@@ -788,10 +788,10 @@ class TestSupport(unittest.TestCase):
             self.assertTrue(linked)
         # The value is cached, so make sure it returns the same value again.
         self.assertIs(linked, support.linked_to_musl())
-        # The unlike libc, the musl version is a triple.
+        # The musl version is either triple or just a major version number.
         if linked:
             self.assertIsInstance(linked, tuple)
-            self.assertEqual(3, len(linked))
+            self.assertIn(len(linked), (1, 3))
             for v in linked:
                 self.assertIsInstance(v, int)
 
diff --git a/Misc/NEWS.d/next/Library/2025-11-15-14-58-12.gh-issue-141600.XY2BXg.rst b/Misc/NEWS.d/next/Library/2025-11-15-14-58-12.gh-issue-141600.XY2BXg.rst
new file mode 100644 (file)
index 0000000..8071246
--- /dev/null
@@ -0,0 +1 @@
+Fix musl version detection on Void Linux.