diff options
author | Christian Heimes <christian@python.org> | 2022-04-23 07:52:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-23 07:52:16 (GMT) |
commit | 9b5ca5405e5a2786b5b3acc0de578f80f8dc9e36 (patch) | |
tree | 2b9bbe7cbd0d10c15a459f37c91e17ac27e97dff /Lib | |
parent | 0daa99f68b7b9f02b37a2f34508f33ae66d95fc4 (diff) | |
download | cpython-9b5ca5405e5a2786b5b3acc0de578f80f8dc9e36.zip cpython-9b5ca5405e5a2786b5b3acc0de578f80f8dc9e36.tar.gz cpython-9b5ca5405e5a2786b5b3acc0de578f80f8dc9e36.tar.bz2 |
gh-84461: Add sys._emscripten_info, improve docs and build (gh-91781)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/support/threading_helper.py | 7 | ||||
-rw-r--r-- | Lib/test/test_sys.py | 8 |
2 files changed, 9 insertions, 6 deletions
diff --git a/Lib/test/support/threading_helper.py b/Lib/test/support/threading_helper.py index 7b636f0..26cbc6f 100644 --- a/Lib/test/support/threading_helper.py +++ b/Lib/test/support/threading_helper.py @@ -222,12 +222,7 @@ def _can_start_thread() -> bool: support (-s USE_PTHREADS / __EMSCRIPTEN_PTHREADS__). """ if sys.platform == "emscripten": - try: - _thread.start_new_thread(lambda: None, ()) - except RuntimeError: - return False - else: - return True + return sys._emscripten_info.pthreads elif sys.platform == "wasi": return False else: diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index b70871f..bbf01b6 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -629,6 +629,14 @@ class SysModuleTest(unittest.TestCase): self.assertIn(info.name, ('nt', 'pthread', 'solaris', None)) self.assertIn(info.lock, ('semaphore', 'mutex+cond', None)) + @unittest.skipUnless(support.is_emscripten, "only available on Emscripten") + def test_emscripten_info(self): + self.assertEqual(len(sys._emscripten_info), 4) + self.assertIsInstance(sys._emscripten_info.emscripten_version, tuple) + self.assertIsInstance(sys._emscripten_info.runtime, (str, type(None))) + self.assertIsInstance(sys._emscripten_info.pthreads, bool) + self.assertIsInstance(sys._emscripten_info.shared_memory, bool) + def test_43581(self): # Can't use sys.stdout, as this is a StringIO object when # the test runs under regrtest. |