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/2001-November/018402.html below:

[Python-Dev] Proposal - KeyboardInterrupt should inherit directly from Exception

[Python-Dev] Proposal - KeyboardInterrupt should inherit directly from Exception [Python-Dev] Proposal - KeyboardInterrupt should inherit directly from ExceptionSkip Montanaro skip@pobox.com (Skip Montanaro)
Wed, 07 Nov 2001 16:45:18 +0100
>>>>> "Greg" == Greg Ward <gward@python.net> writes:

    Skip> That way, the standard catch all except clause can be
    Skip> 
    Skip> try:
    Skip>     fragile code
    Skip> except StandardError:
    Skip>     recover

    Greg> So "fragile code" would be the main loop of a GUI or server,
    Greg> or an eval or exec of user-supplied code (eg. a config file
    Greg> that happens to be Python source) -- that sort of thing?

That's precisely the context this arose in here in Vienna.  I just
stole Andrew's example from c.l.py because it was easier to paste that
than to type my own.

    Greg> Hmmm... does anyone else habitually write

    Greg>   if __name__ == "__main__":
    Greg>       try:
    Greg>           main()
    Greg>       except KeyboardInterrupt:
    Greg>           sys.exit("interrupted")

This suggests one other enhancement to me.  Just as raising SystemExit
doesn't generate a traceback, perhaps the default handling of
KeyboardInterrupt could be configurable so I could set (for example):

    sys.gen_kbi_traceback = 0
    sys.gen_kbi_message = 0

to suppress traceback and/or message output without having to do
explicitly catch it.  The default for both would be 1 to remain
compatible with current behavior.  If you caught the exception, these
would have no effect.

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