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

Remove unsafe 'assert' and replace it with a proper exception #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Steve132
Copy link

I'm working on some improvements to your script with an eye to integrating it with my open source wallet in the future.

One thing I noticed is that on my build environment "assert" is disabled, which leads to bugs because "assert" is not supposed to be used for runtime error checking, only for debug environments.

Assertions should not be used to test for failure cases that can occur because of bad user input or operating system/environment failures, such as a file not being found. Instead, you should raise an exception, or print an error message, or whatever is appropriate. One important reason why assertions should only be used for self-tests of the program is that assertions can be disabled at compile time.

https://wiki.python.org/moin/UsingAssertionsEffectively

So I replaced the assertions with a quick wrapper that works around that bug.

Steve132 added 2 commits June 18, 2018 05:24
I'm working on some improvements to your script with an eye to integrating it with my open source wallet in the future.

One thing I noticed is that on my build environment "assert" is disabled, which leads to bugs because "assert" is not supposed to be used for runtime error checking, only for debug environments.  

>Assertions should *not* be used to test for failure cases that can occur because of bad user input or operating system/environment failures, such as a file not being found. Instead, you should raise an exception, or print an error message, or whatever is appropriate. One important reason why assertions should only be used for self-tests of the program is that assertions can be disabled at compile time. 

https://wiki.python.org/moin/UsingAssertionsEffectively

So I replaced the assertions with a quick wrapper that works around that bug.
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

Successfully merging this pull request may close these issues.

1 participant