From: Xiang Zhang Date: Mon, 27 Feb 2017 03:45:42 +0000 (+0800) Subject: bpo-29376: Fix assertion error in threading._DummyThread.is_alive() (GH-330) X-Git-Tag: v3.6.1rc1~39 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4b6c41768a15fc85e3069603ef89344bd97f79af;p=thirdparty%2FPython%2Fcpython.git bpo-29376: Fix assertion error in threading._DummyThread.is_alive() (GH-330) --- diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index 2c2914fd6d89..6b6c4d220a3b 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 4829ff426e0b..95978d310a2f 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" diff --git a/Misc/NEWS b/Misc/NEWS index 5fad3c82c1a3..c47657fb2835 100644 --- 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.