Deprecated removal

Removing deprecated codes or replacing old codes with more modern idioms.
1. `while 1:`
2. `BaseException`
3. fixed `__bool__`