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

index 2c2914fd6d896936a210538cef78c7457b3b06f6..6b6c4d220a3bd090631156453f09fcf81ff31c72 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 4829ff426e0bfd8871d3cc3d4b59764eb799d2c4..95978d310a2f3aa9780248dac71d0b7bca113d37 100644 (file)
@@ -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"
 
index 283db49c99a1083d34ae3b0ae3fc9e9e018a92fd..a55112750a2aa6eb562c933f5d9fd426ddebdb23 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -249,6 +249,8 @@ Extension Modules
 Library
 -------
 
+- bpo-29376: Fix assertion error in threading._DummyThread.is_alive().
+
 - bpo-28624: Add a test that checks that cwd parameter of Popen() accepts
   PathLike objects.  Patch by Sayan Chowdhury.