_thread compatibility using frozen _dummy_thread

This commit is contained in:
Jeong YunWon
2022-08-17 01:59:10 +09:00
parent 8f683b94d5
commit 9daeaecd6c
6 changed files with 7 additions and 13 deletions

5
Lib/functools.py vendored
View File

@@ -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

5
Lib/reprlib.py vendored
View File

@@ -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'

5
Lib/tempfile.py vendored
View File

@@ -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

2
Lib/zipfile.py vendored
View File

@@ -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

View File

@@ -0,0 +1 @@
../../../Lib/_dummy_thread.py

View File

@@ -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()?;