Skip to content

Don't use asserts for necessary code #83

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

Closed
dhalbert opened this issue Dec 20, 2022 · 0 comments · Fixed by #85
Closed

Don't use asserts for necessary code #83

dhalbert opened this issue Dec 20, 2022 · 0 comments · Fixed by #85

Comments

@dhalbert
Copy link
Contributor

    Using any nonzero `-O` level with mpy-cross causes Python `assert` statements to not be included.

This is not compatible with the way that wiznet5k uses assert statements, because it depends on the assert statement's expression being evaluated for correct operation. For example,

assert self._w5100_init() == 1, "Failed to initialize WIZnet module."

Because Adafruit's circuitpython-build-tools never specify a -O level, this problem will not affect mpy files we generate or ship to users.

However, fixing the way asserts are used (probably by replacing them with a variation on if not condition: raise RuntimeError("message") in the case where the side-effect of the expression is required) would be welcome from contributors.

If you agree with this analysis, I recommend either re-titling and updating the initial comment on this issue, or closing it and opening a fresh one to reflect the conclusion.

Originally posted by @jepler in #67 (comment)

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 a pull request may close this issue.

1 participant