summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorXiang Zhang <angwerzx@126.com>2017-02-27 03:45:42 (GMT)
committerGitHub <noreply@github.com>2017-02-27 03:45:42 (GMT)
commit4b6c41768a15fc85e3069603ef89344bd97f79af (patch)
treeb7a37d5cac439d0ca3b637a7d55a63cb6af21b01 /Lib
parent7e4897a2fb91e49f131a42ed6de88b5185f7dea8 (diff)
downloadcpython-4b6c41768a15fc85e3069603ef89344bd97f79af.zip
cpython-4b6c41768a15fc85e3069603ef89344bd97f79af.tar.gz
cpython-4b6c41768a15fc85e3069603ef89344bd97f79af.tar.bz2
bpo-29376: Fix assertion error in threading._DummyThread.is_alive() (GH-330)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_threading.py3
-rw-r--r--Lib/threading.py4
2 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index 2c2914f..6b6c4d2 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -170,6 +170,9 @@ class ThreadTests(BaseTestCase):
mutex.acquire()
self.assertIn(tid, threading._active)
self.assertIsInstance(threading._active[tid], threading._DummyThread)
+ #Issue 29376
+ self.assertTrue(threading._active[tid].is_alive())
+ self.assertRegex(repr(threading._active[tid]), '_DummyThread')
del threading._active[tid]
# PyThreadState_SetAsyncExc() is a CPython-only gimmick, not (currently)
diff --git a/Lib/threading.py b/Lib/threading.py
index 4829ff4..95978d3 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -1217,6 +1217,10 @@ class _DummyThread(Thread):
def _stop(self):
pass
+ def is_alive(self):
+ assert not self._is_stopped and self._started.is_set()
+ return True
+
def join(self, timeout=None):
assert False, "cannot join a dummy thread"