From 29fb6c017acde20a8d45128910d5dd8dafe8d1e5 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 25 Aug 2025 10:39:43 +0200 Subject: [PATCH 1/2] gh-138130: Fix return value of libc_ver() on Emscripten --- Lib/platform.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/platform.py b/Lib/platform.py index da15bb4717bb96..762f5d06099cf0 100644 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -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') From 2bd3ac5e3734ee3a4b5efe20d76f9b24537f5b01 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 28 Aug 2025 15:17:10 +0200 Subject: [PATCH 2/2] Update test --- Lib/test/test_platform.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index 479649053abc01..6bae3faf9b260d 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -532,8 +532,10 @@ def test_ios_ver(self): 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'):