[Python-Dev] (#19562) Asserts in Python stdlib code (datetime.py)

Mark Janssen dreamingforward at gmail.com
Sat Nov 16 04:32:17 CET 2013

> Should stdlib code use assert at all?
> If user input can trigger an assert, then the code should raise a normal
> exception that will not disappear with -OO.
> If the assert is testing program logic, then it seems that the test belongs
> in the test file, in this case, test/test_datetime.py. For example, consider
> the following (backwards) code.
> Is there any policy on use of assert in stdlib production code?

It is my assertion that assert should only be used where a
system-level problem would occur, where you cannot trap an error

Tacoma, Washington

More information about the Python-Dev mailing list