Chris Angelico <ros...@gmail.com>:

> On Sat, Nov 15, 2014 at 11:12 AM, Marko Rauhamaa <ma...@pacujo.net> wrote:
>> Most importantly, assertion failures are not supposed to be recovered
>> from (within the program). Assertion failures can result in the loss
>> of life and limb. They can result in database corruption. They can
>> result in monetary losses. They can result in smoke coming out of the
>> monitor.
>
> Or, in theory, AssertionError just prevented any of the above from
> happening.

I'd advice against catching AssertionError and trying to recover from it
within the program. You could catch it, log it and reraise it, but since
the failure modes could be completely unexpected (really, by
definition), I would move fault-tolerance outside the failing process
and try to restore a coherent reality from there.

Assertion errors are in the same class with CPython bugs, external
signals (say, SIGKILL), security breaches, hardware failures and the
like.

For expected failure modes, other exceptions are a suitable facility.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to