Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-40280: Misc fixes for wasm32-emscripten (GH-30722) #30722

Merged
merged 1 commit into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Lib/test/test___all__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
from test.support import warnings_helper
import os
import sys
import types

try:
import _multiprocessing
except ModuleNotFoundError:
_multiprocessing = None


class NoAll(RuntimeError):
Expand All @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
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')
Expand Down Expand Up @@ -798,6 +802,7 @@ def test_mutate_exception(self):

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
Expand Down Expand Up @@ -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)"""

Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_compileall.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
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
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_imp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_pty.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_tracemalloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def fork_child(self):
# 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()
Expand Down
2 changes: 2 additions & 0 deletions Tools/wasm/config.site-wasm32-emscripten
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -6384,6 +6384,8 @@ AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
_gdbm
_scproxy
_tkinter
_xxsubinterpreters
grp
nis
ossaudiodev
spwd
Expand Down