summaryrefslogtreecommitdiffstats
path: root/Lib/threading.py
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2023-07-12 18:07:59 (GMT)
committerGitHub <noreply@github.com>2023-07-12 18:07:59 (GMT)
commite4b88c1e4ac129b36f99a534387d64f7b8cda8ef (patch)
tree4a8e0dc10501d120508a2bf2b9f4369420775133 /Lib/threading.py
parentdd1884dc5dc1a540c60e98ea1bc482a51d996564 (diff)
downloadcpython-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.py7
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