Skip to content

Commit bef7097

Browse files
hoodmanemiss-islington
authored andcommitted
pythongh-138130: Fix return value of libc_ver() on Emscripten (pythonGH-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. (cherry picked from commit 11a5fc8) Co-authored-by: Hood Chatham <[email protected]>
1 parent 5ec6d56 commit bef7097

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
@@ -525,8 +525,10 @@ def test_ios_ver(self):
525525
self.assertEqual(override.model, "Whiz")
526526
self.assertTrue(override.is_simulator)
527527

528-
@unittest.skipIf(support.is_emscripten, "Does not apply to Emscripten")
529528
def test_libc_ver(self):
529+
if support.is_emscripten:
530+
assert platform.libc_ver() == ("emscripten", "4.0.12")
531+
return
530532
# check that libc_ver(executable) doesn't raise an exception
531533
if os.path.isdir(sys.executable) and \
532534
os.path.exists(sys.executable+'.exe'):

0 commit comments

Comments
 (0)