]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-29376: Fix assertion error in threading._DummyThread.is_alive() (GH-330)
authorXiang Zhang <angwerzx@126.com>
Mon, 27 Feb 2017 03:45:42 +0000 (11:45 +0800)
committerGitHub <noreply@github.com>
Mon, 27 Feb 2017 03:45:42 +0000 (11:45 +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 5fad3c82c1a3a0b9fe8b69d63103436a31c7b625..c47657fb28357fcdceec30b3a80fe96bf1eafae8 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -69,6 +69,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.