#32508: Add a system check that 'assert' is not disabled
-----------------------------------------+------------------------
               Reporter:  Adam Johnson   |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Uncategorized  |        Version:  master
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 Python's -O flag strips 'assert' statements:
 https://docs.python.org/3/using/cmdline.html#cmdoption-o . A naive user
 might enable this flag to try "make their code go faster", whilst any gain
 would be very marginal.

 Django currently has 89 assert statements guarding against various kinds
 of bad data. It's also common for library or project code to use 'assert'
 without realizing it could be turned off.

 I propose adding a system check to warn or error if the assert statement
 doesn't work. This can be checked with something like:

 {{{
 try:
     assert False
 except AssertionError:
     pass
 else:
     errors.append(checks.Error("Django relies on the 'assert' statement,
 do not disable it with 'python -O'"))
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32508>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.ea7bffd74d2d024b410b16f01dac2a4a%40djangoproject.com.

Reply via email to