﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32508	"Raise proper exceptions instead of using ""assert""."	Adam Johnson	Mateo Radman	"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'""))
}}}
"	Cleanup/optimization	closed	Core (Other)	dev	Normal	fixed		Paolo Melchiorre	Accepted	0	0	0	0	0	0
