A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-March/021509.html below:

[Python-Dev] Breaking bug #411881 into manageable pieces

[Python-Dev] Breaking bug #411881 into manageable pieces [Python-Dev] Breaking bug #411881 into manageable piecesSkip Montanaro skip@pobox.com
Wed, 20 Mar 2002 15:08:32 -0600
(BAW - why does supercite ruin code indentation when quoting???)

    >> There's a standard idiom for this:
    >> 
    >> try:
    >>    ...code...
    >> except KeyboardInterrupt:
    >>    raise
    >> except:
    >>    ...handler...

    aahz> May I suggest yet one more alteration:

    aahz>     try:
    aahz>         ...code...
    aahz>     except (KeyboardInterrupt,SystemExit):
    aahz>         raise
    aahz>     except:
    aahz>         ...handler...

Which reminds me about a proposal I made here last November:

    http://mail.python.org/pipermail/python-dev/2001-November/018394.html

Executive summary: Make KeyboardInterrupt inherit directly from Exception
instead of from StandardError, so your standard idiom becomes:

    try:
        fragile code
    except StandardError:
        recover

Anything that you might generally not want to trap (KeyboardInterrupt and
SystemExit are the usual suspects, but Warning and StopIteration also fall
into this category I think) should not inherit from StandardError.

Skip



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