- Yes.
SyntaxError
isn’t catchable except in cases of dynamically executed code (viaeval
/exec
), because it occurs before the code is actually running. - “Fatal” means “program dies regardless of what the code says”; that doesn’t happen with exceptions in Python, they’re all catchable.
os._exit
can forcibly kill the process, but it does so by bypassing the exception mechanism. - There is no difference between exceptions and errors, so the nomenclature doesn’t matter.
- System-exiting exceptions derive from
BaseException
, but notException
. But they can be caught just like any other exception - Warnings behave differently based on the warnings filter, and deriving from
Exception
means they’re not in the “system-exiting” category AssertionError
is just anotherException
child class, so it’s not “system exiting”. It’s just tied to theassert
statement, which has special semantics.- Things deriving from
BaseException
but notException
(e.g.SystemExit
,KeyboardInterrupt
) are “not reasonable to catch” (or if you do catch them, it should almost always be to log/perform cleanup and rethrow them), everything else (derived fromException
as well) is “conditionally reasonable to catch”. There is no other distinction.
To be clear, “system-exiting” is just a way of saying “things which except Exception:
won’t catch”; if no except
blocks are involved, all exceptions (aside from warnings, which as noted, behave differently based on the warnings filter) are “system-exiting”.