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

@ -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