Skip to content

Commit 11a5fc8

Browse files
authored
gh-138130: Fix return value of libc_ver() on Emscripten (#138132)
Emscripten's libc is a hybrid of musl and llvm libc; but it reports that it is "glibc". This modifies the return value of `platform.libc_ver()` to return something that is Emscripten-specific.
1 parent 78acd8e commit 11a5fc8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Lib/platform.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ def libc_ver(executable=None, lib='', version='', chunksize=16384):
173173
174174
"""
175175
if not executable:
176+
if sys.platform == "emscripten":
177+
# Emscripten's os.confstr reports that it is glibc, so special case
178+
# it.
179+
ver = ".".join(str(x) for x in sys._emscripten_info.emscripten_version)
180+
return ("emscripten", ver)
176181
try:
177182
ver = os.confstr('CS_GNU_LIBC_VERSION')
178183
# parse 'glibc 2.28' as ('glibc', '2.28')

Lib/test/test_platform.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,10 @@ def test_ios_ver(self):
532532
self.assertEqual(override.model, "Whiz")
533533
self.assertTrue(override.is_simulator)
534534

535-
@unittest.skipIf(support.is_emscripten, "Does not apply to Emscripten")
536535
def test_libc_ver(self):
536+
if support.is_emscripten:
537+
assert platform.libc_ver() == ("emscripten", "4.0.12")
538+
return
537539
# check that libc_ver(executable) doesn't raise an exception
538540
if os.path.isdir(sys.executable) and \
539541
os.path.exists(sys.executable+'.exe'):

0 commit comments

Comments
 (0)