]> granicus.if.org Git - python/commitdiff
bpo-29376: Fix assertion error in threading._DummyThread.is_alive() (GH-329)
authorXiang Zhang <angwerzx@126.com>
Mon, 27 Feb 2017 03:46:37 +0000 (11:46 +0800)
committerGitHub <noreply@github.com>
Mon, 27 Feb 2017 03:46:37 +0000 (11:46 +0800)
Lib/test/test_threading.py
Lib/threading.py
Misc/NEWS

index b63050982ab694e4ad8f7dbf53fd21c907dc6c0c..83a99023d7a8aebe54b6461ec4b1599fb455d630 100644 (file)
@@ -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)
index 06b7b9b4fac598b6cd350b11023a8f34b45e646a..c40d3307b2f2651757a9f64b1fc1ba9b3593ca77 100644 (file)
@@ -1215,6 +1215,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"
 
index 8a7e1b5cd9c16e7ee99ef445833ce654074c9047..635f413dc74be89296278c4df99a1989d7140469 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -32,6 +32,8 @@ Extension Modules
 Library
 -------
 
+- bpo-29376: Fix assertion error in threading._DummyThread.is_alive().
+
 - bpo-29110: Fix file object leak in aifc.open() when file is given as a
   filesystem path and is not in valid AIFF format. Patch by Anthony Zhang.