Skip to content

Commit f3a9fab

Browse files
authored
bpo-29376: Fix assertion error in threading._DummyThread.is_alive() (GH-236)
1 parent 1f5639c commit f3a9fab

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

Lib/test/test_threading.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ def f(mutex):
170170
mutex.acquire()
171171
self.assertIn(tid, threading._active)
172172
self.assertIsInstance(threading._active[tid], threading._DummyThread)
173+
#Issue 29376
174+
self.assertTrue(threading._active[tid].is_alive())
175+
self.assertRegex(repr(threading._active[tid]), '_DummyThread')
173176
del threading._active[tid]
174177

175178
# PyThreadState_SetAsyncExc() is a CPython-only gimmick, not (currently)

Lib/threading.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,10 @@ def __init__(self):
12171217
def _stop(self):
12181218
pass
12191219

1220+
def is_alive(self):
1221+
assert not self._is_stopped and self._started.is_set()
1222+
return True
1223+
12201224
def join(self, timeout=None):
12211225
assert False, "cannot join a dummy thread"
12221226

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ Extension Modules
249249
Library
250250
-------
251251

252+
- bpo-29376: Fix assertion error in threading._DummyThread.is_alive().
253+
252254
- bpo-28624: Add a test that checks that cwd parameter of Popen() accepts
253255
PathLike objects. Patch by Sayan Chowdhury.
254256

0 commit comments

Comments
 (0)