]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-138130: Fix return value of libc_ver() on Emscripten (GH-138132) (#138312)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 5 Oct 2025 13:03:49 +0000 (15:03 +0200)
committerGitHub <noreply@github.com>
Sun, 5 Oct 2025 13:03:49 +0000 (16:03 +0300)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Lib/platform.py
Lib/test/test_platform.py

index 86141f072d20e43ca9a30d00c8b1e2a6b151b524..784b6b749b75245f8fe5de5eee25674071aa0c07 100644 (file)
@@ -173,6 +173,11 @@ def libc_ver(executable=None, lib='', version='', chunksize=16384):
 
     """
     if not executable:
+        if sys.platform == "emscripten":
+            # Emscripten's os.confstr reports that it is glibc, so special case
+            # it.
+            ver = ".".join(str(x) for x in sys._emscripten_info.emscripten_version)
+            return ("emscripten", ver)
         try:
             ver = os.confstr('CS_GNU_LIBC_VERSION')
             # parse 'glibc 2.28' as ('glibc', '2.28')
index 6224c989e6552b5e6e17872b65000c1a1295bc26..187a3d548091057c458d48bac2edf9d22e8d3490 100644 (file)
@@ -525,8 +525,10 @@ class PlatformTest(unittest.TestCase):
             self.assertEqual(override.model, "Whiz")
             self.assertTrue(override.is_simulator)
 
-    @unittest.skipIf(support.is_emscripten, "Does not apply to Emscripten")
     def test_libc_ver(self):
+        if support.is_emscripten:
+            assert platform.libc_ver() == ("emscripten", "4.0.12")
+            return
         # check that libc_ver(executable) doesn't raise an exception
         if os.path.isdir(sys.executable) and \
            os.path.exists(sys.executable+'.exe'):