[Python-Dev] Proposing a sys.special_exceptions tuple
ncoghlan at email.com
Thu Sep 30 12:21:47 CEST 2004
I spent some time the other day looking at the use of bare except statements in
the standard library.
Many of them seemed to fall into the category of 'need to catch anything user
code is likely to throw, but shouldn't be masking SystemExit, StopIteration,
KeyboardInterrupt, MemoryError, etc'.
Changing them to "except Exception:" doesn't help, since all of the above still
fit into that category (Tim posted a message recently about rearranging the
Exception heirarchy to fix this. Backwards compatibility woes pretty much killed
the discussion though).
However, another possibility occurred to me:
# Do stuff
# Deal with all the mundane stuff
With an appropriately defined tuple, that makes it easy for people to "do the
right thing" with regards to critical exceptions. Such a tuple could also be
useful for invoking isinstance() and issubclass().
Who knows? If something like this caught on, it might some day be possible to
kill a Python script with a single press of Ctrl-C };>
More information about the Python-Dev