diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2023-07-12 18:07:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-12 18:07:59 (GMT) |
commit | e4b88c1e4ac129b36f99a534387d64f7b8cda8ef (patch) | |
tree | 4a8e0dc10501d120508a2bf2b9f4369420775133 /Lib/threading.py | |
parent | dd1884dc5dc1a540c60e98ea1bc482a51d996564 (diff) | |
download | cpython-e4b88c1e4ac129b36f99a534387d64f7b8cda8ef.zip cpython-e4b88c1e4ac129b36f99a534387d64f7b8cda8ef.tar.gz cpython-e4b88c1e4ac129b36f99a534387d64f7b8cda8ef.tar.bz2 |
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.
Diffstat (limited to 'Lib/threading.py')
-rw-r--r-- | Lib/threading.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/threading.py b/Lib/threading.py index df27387..e036cb8 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -1451,11 +1451,12 @@ class _DummyThread(Thread): pass def is_alive(self): - assert not self._is_stopped and self._started.is_set() - return True + if not self._is_stopped and self._started.is_set(): + return True + raise RuntimeError("thread is not alive") def join(self, timeout=None): - assert False, "cannot join a dummy thread" + raise RuntimeError("cannot join a dummy thread") # Global API functions |