diff --git a/Lib/functools.py b/Lib/functools.py index 74db9969ad..8decc874e1 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -18,10 +18,7 @@ from abc import get_cache_token from collections import namedtuple # import types, weakref # Deferred to single_dispatch() from reprlib import recursive_repr -try: - from _thread import RLock -except ModuleNotFoundError: - from _dummy_thread import RLock +from _thread import RLock from types import GenericAlias diff --git a/Lib/reprlib.py b/Lib/reprlib.py index 6b0283b793..616b3439b5 100644 --- a/Lib/reprlib.py +++ b/Lib/reprlib.py @@ -4,10 +4,7 @@ __all__ = ["Repr", "repr", "recursive_repr"] import builtins from itertools import islice -try: - from _thread import get_ident -except ModuleNotFoundError: - from _dummy_thread import get_ident +from _thread import get_ident def recursive_repr(fillvalue='...'): 'Decorator to make a repr function return fillvalue for a recursive call' diff --git a/Lib/tempfile.py b/Lib/tempfile.py index 17b380c290..3aceb3f70f 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -47,10 +47,7 @@ import sys as _sys import types as _types import weakref as _weakref -try: - import _thread -except ImportError: - import _dummy_thread as _thread +import _thread _allocate_lock = _thread.allocate_lock _text_openflags = _os.O_RDWR | _os.O_CREAT | _os.O_EXCL diff --git a/Lib/zipfile.py b/Lib/zipfile.py index d94310164d..ef1eb47f9f 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -22,7 +22,7 @@ import sys try: import threading except ImportError: - import _dummy_thread as threading + import dummy_threading as threading import time import contextlib import pathlib diff --git a/vm/Lib/python_builtins/_thread.py b/vm/Lib/python_builtins/_thread.py new file mode 120000 index 0000000000..fa4a34c4fb --- /dev/null +++ b/vm/Lib/python_builtins/_thread.py @@ -0,0 +1 @@ +../../../Lib/_dummy_thread.py \ No newline at end of file diff --git a/vm/src/vm/mod.rs b/vm/src/vm/mod.rs index e98ec694d5..526239e8ff 100644 --- a/vm/src/vm/mod.rs +++ b/vm/src/vm/mod.rs @@ -233,6 +233,8 @@ impl VirtualMachine { let mut essential_init = || -> PyResult { #[cfg(not(target_arch = "wasm32"))] import::import_builtin(self, "_signal")?; + #[cfg(not(feature = "threading"))] + import::import_frozen(self, "_thread")?; let importlib = import::init_importlib_base(self)?; self.import_utf8_encodings()?;