]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40280: Misc fixes for wasm32-emscripten (GH-30722)
authorChristian Heimes <christian@python.org>
Thu, 20 Jan 2022 17:56:33 +0000 (19:56 +0200)
committerGitHub <noreply@github.com>
Thu, 20 Jan 2022 17:56:33 +0000 (18:56 +0100)
Lib/test/test___all__.py
Lib/test/test_capi.py
Lib/test/test_compileall.py
Lib/test/test_imp.py
Lib/test/test_pty.py
Lib/test/test_tracemalloc.py
Tools/wasm/config.site-wasm32-emscripten
configure
configure.ac

index 15f42d2d114a68629182d539163a941eb0b8921e..81293e15f8163e54f142db0a2030f61abcc0c218 100644 (file)
@@ -3,6 +3,12 @@ from test import support
 from test.support import warnings_helper
 import os
 import sys
+import types
+
+try:
+    import _multiprocessing
+except ModuleNotFoundError:
+    _multiprocessing = None
 
 
 class NoAll(RuntimeError):
@@ -14,6 +20,17 @@ class FailedImport(RuntimeError):
 
 class AllTest(unittest.TestCase):
 
+    def setUp(self):
+        # concurrent.futures uses a __getattr__ hook. Its __all__ triggers
+        # import of a submodule, which fails when _multiprocessing is not
+        # available.
+        if _multiprocessing is None:
+            sys.modules["_multiprocessing"] = types.ModuleType("_multiprocessing")
+
+    def tearDown(self):
+        if _multiprocessing is None:
+            sys.modules.pop("_multiprocessing")
+
     def check_all(self, modname):
         names = {}
         with warnings_helper.check_warnings(
index 7ada8406a3584966065036210e57b2074e4f54d3..0957f3253d7a66d1e65be5dcf26925a1307c3d71 100644 (file)
@@ -26,6 +26,10 @@ try:
     import _posixsubprocess
 except ImportError:
     _posixsubprocess = None
+try:
+    import _testmultiphase
+except ImportError:
+    _testmultiphase = None
 
 # Skip this test if the _testcapi module isn't available.
 _testcapi = import_helper.import_module('_testcapi')
@@ -798,6 +802,7 @@ class SubinterpreterTest(unittest.TestCase):
 
         self.assertFalse(hasattr(binascii.Error, "foobar"))
 
+    @unittest.skipIf(_testmultiphase is None, "test requires _testmultiphase module")
     def test_module_state_shared_in_global(self):
         """
         bpo-44050: Extension module state should be shared between interpreters
@@ -991,6 +996,7 @@ class PyMemDefaultTests(PyMemDebugTests):
     PYTHONMALLOC = ''
 
 
+@unittest.skipIf(_testmultiphase is None, "test requires _testmultiphase module")
 class Test_ModuleStateAccess(unittest.TestCase):
     """Test access to module start (PEP 573)"""
 
index 33f0c939325f5320ff5e9970f4b2571bb4ffe9ca..e207cf8f1793b6d9da79a55af646667f63243df3 100644 (file)
@@ -15,14 +15,14 @@ import time
 import unittest
 
 from unittest import mock, skipUnless
-from concurrent.futures import ProcessPoolExecutor
 try:
     # compileall relies on ProcessPoolExecutor if ProcessPoolExecutor exists
     # and it can function.
+    from concurrent.futures import ProcessPoolExecutor
     from concurrent.futures.process import _check_system_limits
     _check_system_limits()
     _have_multiprocessing = True
-except NotImplementedError:
+except (NotImplementedError, ModuleNotFoundError):
     _have_multiprocessing = False
 
 from test import support
index 1a21025fe6eafff05ec4dd7167ad80e06fba8d4f..35e9a2a186552f7ad66266dac77921802f21ec30 100644 (file)
@@ -23,7 +23,7 @@ def requires_load_dynamic(meth):
     """Decorator to skip a test if not running under CPython or lacking
     imp.load_dynamic()."""
     meth = support.cpython_only(meth)
-    return unittest.skipIf(not hasattr(imp, 'load_dynamic'),
+    return unittest.skipIf(getattr(imp, 'load_dynamic', None) is None,
                            'imp.load_dynamic() required')(meth)
 
 
index 0c178127571b07c8310de09c52306b2ea8da5466..0781cde1e1582ec1545f6cb16b98f04a4c88c045 100644 (file)
@@ -1,8 +1,9 @@
 from test.support import verbose, reap_children
 from test.support.import_helper import import_module
 
-# Skip these tests if termios is not available
+# Skip these tests if termios or fcntl are not available
 import_module('termios')
+import_module("fcntl")
 
 import errno
 import os
index 82be98dfd8f5ac6765d703b4a1a0dc08b4f3c6dd..d2a5ede61e3ff1ef9a6d98ce797c84bfd1c848cd 100644 (file)
@@ -346,7 +346,7 @@ class TestTracemallocEnabled(unittest.TestCase):
         # everything is fine
         return 0
 
-    @unittest.skipUnless(hasattr(os, 'fork'), 'need os.fork()')
+    @support.requires_fork()
     def test_fork(self):
         # check that tracemalloc is still working after fork
         pid = os.fork()
index c15e4fc6b64b11154d14b6e6573bc47a1ed5ba2b..413506bbc9abd7dc727835651245b8747778e925 100644 (file)
@@ -58,12 +58,14 @@ ac_cv_func_fchmodat=no
 ac_cv_func_dup3=no
 
 # Syscalls not implemented in emscripten
+# [Errno 52] Function not implemented
 ac_cv_func_preadv2=no
 ac_cv_func_preadv=no
 ac_cv_func_pwritev2=no
 ac_cv_func_pwritev=no
 ac_cv_func_pipe2=no
 ac_cv_func_nice=no
+ac_cv_func_setitimer=no
 
 # Syscalls that resulted in a segfault
 ac_cv_func_utimensat=no
index 7236e0930e15bb6eaf6bf80c234f44977bdb560c..402e626b6992d1718fd3af6e67d357b9a470194f 100755 (executable)
--- a/configure
+++ b/configure
@@ -21323,7 +21323,7 @@ case $ac_sys_system/$ac_sys_emscripten_target in #(
    ;; #(
       Emscripten/node) :
 
-    py_stdlib_not_available="_ctypes _curses _curses_panel _dbm _gdbm _scproxy _tkinter nis ossaudiodev spwd syslog"
+    py_stdlib_not_available="_ctypes _curses _curses_panel _dbm _gdbm _scproxy _tkinter _xxsubinterpreters grp nis ossaudiodev spwd syslog"
    ;; #(
   *) :
     py_stdlib_not_available="_scproxy"
index aea12128c1217da4592a37f6b950bfc55867f2a5..9c9a3385767360155abf09966aaf06632ed79af0 100644 (file)
@@ -6384,6 +6384,8 @@ AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
       _gdbm
       _scproxy
       _tkinter
+      _xxsubinterpreters
+      grp
       nis
       ossaudiodev
       spwd