isinstance(SystemExit(1), Exception) evals to True, but this snippet prints "caught by bare except SystemExit(1,)".
try:
sys.exit(0)
except Exception, e:
print 'caught by except Exception', str(e)
except:
print 'caught by bare except', repr(sys.exc_info()[1])
My testing environment is Python 2.6.
isinstance(SystemExit(1), Exception)is False on Python 2.6. Exception hierarchy in this version of Python was changed since Python 2.4.
E.g.
KeyboardInterruptis not subclass ofExceptionany more.See more info http://docs.python.org/release/2.6.6/library/exceptions.html#exception-hierarchy