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

Use of assert #77

Open
davidwilby opened this issue Aug 22, 2024 · 0 comments
Open

Use of assert #77

davidwilby opened this issue Aug 22, 2024 · 0 comments

Comments

@davidwilby
Copy link

As discussed:

As far as I understand, assert in "production" code isn't advised. This is mainly because when run in optimized mode python -0 <script.py> (or via some other means), the internal __debug__ variable is set to False and stops respecting assert statements. (See official docs: https://docs.python.org/3/reference/simple_stmts.html#the-assert-statement)

assert is essentially:

if __debug__:
    if not expression: raise AssertionError

Now, this is potentially a minor case, but if used in a production setting, it's possible that PolarRoute could be used with python's optimized mode and fall over.

Instead of assert, errors should be handled explicitly with raise (as far as I understand it).

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

1 participant