Skip to content

Commit 8400ae2

Browse files
authored
bpo-29376: Fix assertion error in threading._DummyThread.is_alive() (GH-329)
1 parent b7fb1e2 commit 8400ae2

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
@@ -1215,6 +1215,10 @@ def __init__(self):
12151215
def _stop(self):
12161216
pass
12171217

1218+
def is_alive(self):
1219+
assert not self._is_stopped and self._started.is_set()
1220+
return True
1221+
12181222
def join(self, timeout=None):
12191223
assert False, "cannot join a dummy thread"
12201224

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Extension Modules
3232
Library
3333
-------
3434

35+
- bpo-29376: Fix assertion error in threading._DummyThread.is_alive().
36+
3537
- bpo-29110: Fix file object leak in aifc.open() when file is given as a
3638
filesystem path and is not in valid AIFF format. Patch by Anthony Zhang.
3739

0 commit comments

Comments
 (0)