flask-lastuser
flask-lastuser copied to clipboard
Do not use assert in validators
As per Python's documentation for the assert
statement, an assert expression
is equivalent to:
if __debug__:
if not expression: raise AssertionError
Also:
In the current implementation, the built-in variable
__debug__
isTrue
under normal circumstances,False
when optimization is requested (command line option-O
). The current code generator emits no code for an assert statement when optimization is requested at compile time.
This makes using assert
for validators unreliable. Flask-Lastuser uses them in a few places. These should be replaced with an explicit if not expression: raise ValueError