A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2004-September/049139.html below:

[Python-Dev] Proposing a sys.special_exceptions tuple

[Python-Dev] Proposing a sys.special_exceptions tupleNick Coghlan 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:

try:
  # Do stuff
except sys.special_exceptions:
  raise
except:
  # 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 };>

Cheers,
Nick.

-- 
Nick Coghlan
Brisbane, Australia
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4