From 31368435652449f47aa52c0492da70fead6cf5ce Mon Sep 17 00:00:00 2001 From: Xiang Zhang Date: Wed, 22 Feb 2017 18:51:26 +0800 Subject: [PATCH 1/2] fix assertion error in threading._DummyThread.is_alive() --- Lib/test/test_threading.py | 3 +++ Lib/threading.py | 4 ++++ Misc/NEWS | 2 ++ 3 files changed, 9 insertions(+) diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index 2c2914fd6d8969..6b6c4d220a3bd0 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -170,6 +170,9 @@ def f(mutex): 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 4829ff426e0bfd..95978d310a2f3a 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -1217,6 +1217,10 @@ def __init__(self): 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 4d1cf298ae5df9..f458b7c8f2e6c7 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -239,6 +239,8 @@ Extension Modules Library ------- +- bpo-29376: Fix assertion error in threading._DummyThread.is_alive(). + - bpo-29532: Altering a kwarg dictionary passed to functools.partial() no longer affects a partial object after creation. From e65317de7ed52071a9a09698fc54f959525dbdb6 Mon Sep 17 00:00:00 2001 From: Xiang Zhang Date: Mon, 27 Feb 2017 10:41:41 +0800 Subject: [PATCH 2/2] fix style --- Misc/NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/Misc/NEWS b/Misc/NEWS index e08c9c146d7b98..a55112750a2aa6 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -250,6 +250,7 @@ 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.