Rewrite 'assert' statements as if/raise? #7832
Unanswered
adamchainz
asked this question in
Ideas & Suggestions
Replies: 1 comment 1 reply
-
Thanks Adam! I'd probably prefer not. (Tho I'm open to being persuaded here.) 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? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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".Beta Was this translation helpful? Give feedback.
All reactions