Skip to content

Commit c02e860

Browse files
authored
bpo-40280: Misc fixes for wasm32-emscripten (GH-30722)
1 parent ef3ef6f commit c02e860

9 files changed

+34
-6
lines changed

Lib/test/test___all__.py

+17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
from test.support import warnings_helper
44
import os
55
import sys
6+
import types
7+
8+
try:
9+
import _multiprocessing
10+
except ModuleNotFoundError:
11+
_multiprocessing = None
612

713

814
class NoAll(RuntimeError):
@@ -14,6 +20,17 @@ class FailedImport(RuntimeError):
1420

1521
class AllTest(unittest.TestCase):
1622

23+
def setUp(self):
24+
# concurrent.futures uses a __getattr__ hook. Its __all__ triggers
25+
# import of a submodule, which fails when _multiprocessing is not
26+
# available.
27+
if _multiprocessing is None:
28+
sys.modules["_multiprocessing"] = types.ModuleType("_multiprocessing")
29+
30+
def tearDown(self):
31+
if _multiprocessing is None:
32+
sys.modules.pop("_multiprocessing")
33+
1734
def check_all(self, modname):
1835
names = {}
1936
with warnings_helper.check_warnings(

Lib/test/test_capi.py

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
import _posixsubprocess
2727
except ImportError:
2828
_posixsubprocess = None
29+
try:
30+
import _testmultiphase
31+
except ImportError:
32+
_testmultiphase = None
2933

3034
# Skip this test if the _testcapi module isn't available.
3135
_testcapi = import_helper.import_module('_testcapi')
@@ -798,6 +802,7 @@ def test_mutate_exception(self):
798802

799803
self.assertFalse(hasattr(binascii.Error, "foobar"))
800804

805+
@unittest.skipIf(_testmultiphase is None, "test requires _testmultiphase module")
801806
def test_module_state_shared_in_global(self):
802807
"""
803808
bpo-44050: Extension module state should be shared between interpreters
@@ -991,6 +996,7 @@ class PyMemDefaultTests(PyMemDebugTests):
991996
PYTHONMALLOC = ''
992997

993998

999+
@unittest.skipIf(_testmultiphase is None, "test requires _testmultiphase module")
9941000
class Test_ModuleStateAccess(unittest.TestCase):
9951001
"""Test access to module start (PEP 573)"""
9961002

Lib/test/test_compileall.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
import unittest
1616

1717
from unittest import mock, skipUnless
18-
from concurrent.futures import ProcessPoolExecutor
1918
try:
2019
# compileall relies on ProcessPoolExecutor if ProcessPoolExecutor exists
2120
# and it can function.
21+
from concurrent.futures import ProcessPoolExecutor
2222
from concurrent.futures.process import _check_system_limits
2323
_check_system_limits()
2424
_have_multiprocessing = True
25-
except NotImplementedError:
25+
except (NotImplementedError, ModuleNotFoundError):
2626
_have_multiprocessing = False
2727

2828
from test import support

Lib/test/test_imp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def requires_load_dynamic(meth):
2323
"""Decorator to skip a test if not running under CPython or lacking
2424
imp.load_dynamic()."""
2525
meth = support.cpython_only(meth)
26-
return unittest.skipIf(not hasattr(imp, 'load_dynamic'),
26+
return unittest.skipIf(getattr(imp, 'load_dynamic', None) is None,
2727
'imp.load_dynamic() required')(meth)
2828

2929

Lib/test/test_pty.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from test.support import verbose, reap_children
22
from test.support.import_helper import import_module
33

4-
# Skip these tests if termios is not available
4+
# Skip these tests if termios or fcntl are not available
55
import_module('termios')
6+
import_module("fcntl")
67

78
import errno
89
import os

Lib/test/test_tracemalloc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def fork_child(self):
346346
# everything is fine
347347
return 0
348348

349-
@unittest.skipUnless(hasattr(os, 'fork'), 'need os.fork()')
349+
@support.requires_fork()
350350
def test_fork(self):
351351
# check that tracemalloc is still working after fork
352352
pid = os.fork()

Tools/wasm/config.site-wasm32-emscripten

+2
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ ac_cv_func_fchmodat=no
5858
ac_cv_func_dup3=no
5959

6060
# Syscalls not implemented in emscripten
61+
# [Errno 52] Function not implemented
6162
ac_cv_func_preadv2=no
6263
ac_cv_func_preadv=no
6364
ac_cv_func_pwritev2=no
6465
ac_cv_func_pwritev=no
6566
ac_cv_func_pipe2=no
6667
ac_cv_func_nice=no
68+
ac_cv_func_setitimer=no
6769

6870
# Syscalls that resulted in a segfault
6971
ac_cv_func_utimensat=no

configure

+1-1
Original file line numberDiff line numberDiff line change
@@ -21323,7 +21323,7 @@ case $ac_sys_system/$ac_sys_emscripten_target in #(
2132321323
;; #(
2132421324
Emscripten/node) :
2132521325

21326-
py_stdlib_not_available="_ctypes _curses _curses_panel _dbm _gdbm _scproxy _tkinter nis ossaudiodev spwd syslog"
21326+
py_stdlib_not_available="_ctypes _curses _curses_panel _dbm _gdbm _scproxy _tkinter _xxsubinterpreters grp nis ossaudiodev spwd syslog"
2132721327
;; #(
2132821328
*) :
2132921329
py_stdlib_not_available="_scproxy"

configure.ac

+2
Original file line numberDiff line numberDiff line change
@@ -6384,6 +6384,8 @@ AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
63846384
_gdbm
63856385
_scproxy
63866386
_tkinter
6387+
_xxsubinterpreters
6388+
grp
63876389
nis
63886390
ossaudiodev
63896391
spwd

0 commit comments

Comments
 (0)