R: [Python-Dev] Deprecating string exceptions

Guido van Rossum guido@python.org
Thu, 28 Mar 2002 10:11:17 -0500


> Just to make sure I'm not missing something (I probably am), I still think
> the recommended catch-all except construct should become "except
> StandardError:" with KeyboardInterrupt migrated to inherit from Exception
> instead of StandardError.

I think I didn't pay attention when that was being discussed before.
I definitely don't like to make "except:" mean anyting besides "catch
*all* exceptions."

There are too many different use cases to favor a specific
non-obvious; for example, the runcode() method in class
InteractiveInterpreter() in code.py needs to catch all exceptions
including KeyboardInterrupt but excluding SystemExit.  Also note that
StopIteration and the warning categories don't derive from
StandardError; but if any of these is accidentally raised, I'd want my
"except:" clause to catch it!  And, while sometimes it's confusing
that SystemExit is caught by "except:", it's really hard to debug why
your program exits without any warning or traceback when a rogue
library function raises SystemExit.

--Guido van Rossum (home page: http://www.python.org/~guido/)