Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise exceptions instead of using assertions #85

Open
MocktaiLEngineer opened this issue Jul 11, 2023 · 2 comments
Open

Raise exceptions instead of using assertions #85

MocktaiLEngineer opened this issue Jul 11, 2023 · 2 comments

Comments

@MocktaiLEngineer
Copy link

assert base > 0

Assertions can't be relied upon for control flow because they can be disabled, as per the following -

$ python --help
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
...
-O     : remove assert and __debug__-dependent statements; add .opt-1 before
         .pyc extension; also PYTHONOPTIMIZE=x
-OO    : do -O changes and also discard docstrings; add .opt-2 before
         .pyc extension
...

Would you be open to me changing these assertions to other appropriate exceptions as I encounter them?

@samueljsb
Copy link
Contributor

Hi! Sorry for leaving you hanging for so long. You're absolutely right about assertions being no good here. We'd love to see this fixed to raise a better exception.

@thejasmeetsingh
Copy link

Hey @samueljsb
Just raised a PR with regards to this issue: #137

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants