Skip to content

Commit 9daeaec

Browse files
committed
_thread compatibility using frozen _dummy_thread
1 parent 8f683b9 commit 9daeaec

6 files changed

Lines changed: 7 additions & 13 deletions

File tree

Lib/functools.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
from collections import namedtuple
1919
# import types, weakref # Deferred to single_dispatch()
2020
from reprlib import recursive_repr
21-
try:
22-
from _thread import RLock
23-
except ModuleNotFoundError:
24-
from _dummy_thread import RLock
21+
from _thread import RLock
2522
from types import GenericAlias
2623

2724

Lib/reprlib.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
import builtins
66
from itertools import islice
7-
try:
8-
from _thread import get_ident
9-
except ModuleNotFoundError:
10-
from _dummy_thread import get_ident
7+
from _thread import get_ident
118

129
def recursive_repr(fillvalue='...'):
1310
'Decorator to make a repr function return fillvalue for a recursive call'

Lib/tempfile.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@
4747
import types as _types
4848
import weakref as _weakref
4949

50-
try:
51-
import _thread
52-
except ImportError:
53-
import _dummy_thread as _thread
50+
import _thread
5451
_allocate_lock = _thread.allocate_lock
5552

5653
_text_openflags = _os.O_RDWR | _os.O_CREAT | _os.O_EXCL

Lib/zipfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
try:
2323
import threading
2424
except ImportError:
25-
import _dummy_thread as threading
25+
import dummy_threading as threading
2626
import time
2727
import contextlib
2828
import pathlib

vm/Lib/python_builtins/_thread.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../Lib/_dummy_thread.py

vm/src/vm/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ impl VirtualMachine {
233233
let mut essential_init = || -> PyResult {
234234
#[cfg(not(target_arch = "wasm32"))]
235235
import::import_builtin(self, "_signal")?;
236+
#[cfg(not(feature = "threading"))]
237+
import::import_frozen(self, "_thread")?;
236238
let importlib = import::init_importlib_base(self)?;
237239
self.import_utf8_encodings()?;
238240

0 commit comments

Comments
 (0)