gh-106236: Replace assert with raise RuntimeError in threading.py (#106237)

Replace `assert` with `raise ` in `threading.py` so that -OO does not alter _DummyThread behavior.
This commit is contained in:
Nikita Sobolev 2023-07-12 21:07:59 +03:00 committed by GitHub
parent dd1884dc5d
commit e4b88c1e4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View file

@ -251,6 +251,14 @@ class ThreadTests(BaseTestCase):
#Issue 29376
self.assertTrue(threading._active[tid].is_alive())
self.assertRegex(repr(threading._active[tid]), '_DummyThread')
# Issue gh-106236:
with self.assertRaises(RuntimeError):
threading._active[tid].join()
threading._active[tid]._started.clear()
with self.assertRaises(RuntimeError):
threading._active[tid].is_alive()
del threading._active[tid]
# PyThreadState_SetAsyncExc() is a CPython-only gimmick, not (currently)