You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have reduced the issue to the simplest possible case.
Python's -O flag, enables "optimized mode" which, among other things, disables the assert statement. A naive user may activate it to try speed up their application. DRF has many uses of assert in its library code (not tests) to guard against bad conditions. Rewriting those assert statements as an if check and a raise of an appropriate exception would allow it to continue functioning in "optimized mode".
The text was updated successfully, but these errors were encountered:
I'd probably prefer not. If a user is turning off assertions, then, well, let 'em turn off assertions.
But how about this, shall we get this discussion to a more concrete point first, by taking a single specific example of one of the assert statements in question, to help figure out what the benefits/trade-offs would look like in a particular concrete case?
Checklist
Python's
-O
flag, enables "optimized mode" which, among other things, disables theassert
statement. A naive user may activate it to try speed up their application. DRF has many uses ofassert
in its library code (not tests) to guard against bad conditions. Rewriting thoseassert
statements as anif
check and araise
of an appropriate exception would allow it to continue functioning in "optimized mode".The text was updated successfully, but these errors were encountered: