Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #2962
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <malaclypse2@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.04; 'instance,': 0.05; 'exits': 0.07; 'interpreter': 0.07; 'raised': 0.07; 'url:bugs': 0.07; 'python': 0.07; 'bug:': 0.09; 'exceptions': 0.09; 'hits': 0.09; 'received:mail- bw0-f46.google.com': 0.09; 'sun,': 0.09; 'url:activestate': 0.09; 'pm,': 0.11; 'url:code': 0.11; 'exception': 0.12; 'wrote:': 0.14; 'received:209.85.214.46': 0.16; 'threading': 0.16; 'uncaught': 0.16; 'url:sys': 0.16; 'describes': 0.19; 'everyone,': 0.19; 'header:In-Reply-To:1': 0.22; 'jason': 0.22; 'sound': 0.22; 'module,': 0.23; 'replacing': 0.23; 'example': 0.24; 'classes': 0.26; 'function': 0.27; 'message-id:@mail.gmail.com': 0.28; 'problem': 0.29; 'exit': 0.29; "python's": 0.29; 'url:library': 0.31; 'to:addr:python-list': 0.32; 'another': 0.32; 'url:docs': 0.33; 'bit': 0.33; 'with.': 0.33; '(for': 0.33; 'using': 0.34; 'skip:" 10': 0.34; 'change': 0.34; 'there': 0.35; 'function.': 0.35; 'some': 0.37; 'received:209.85': 0.37; 'url:python': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'goes': 0.38; 'but': 0.38; 'url:org': 0.38; 'received:209.85.214': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'header:Received:5': 0.40; 'simple': 0.60; 'here:': 0.61; '2011': 0.62; 'strange': 0.65; 'subject:program': 0.68; 'strategy': 0.71; 'desire,': 0.84; '\xc2\xa0it': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=g1GnB71wd76ay0NzuU7asvVA6LSe8QSNO8KjBnwxd5k=; b=kGK5j0fo9UhqbxHVmvhqY83+dtiZHqdSZzzKJdVKxyndhAcDZqCs/Y+EHmbHZXIGHr Md8WiInUKu72llAZcgiu5HlwRPv/cUmzWif20ZMBZqhs7BrFn5KJQWck8UvEyvTLlE0v g8g8FFPzlkmKELcfoDxlvF+OPtGr+PflH/PTQ= |
| DomainKey-Signature | a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=M6CC8uLBAOQpHiZGCpjFHx9PAMc4mQ7eWfGb8Yox1iLzpx8ivtoG2MNah9HbXlwlAe scra0HnZfokzuOUolOvP2ygoFsvGRjNSkBQJQN1Vt0IIJ2ITn9zxqkWHi4qgwv6uyceB UH9oAVm9tLjHkok/+mboBYjmhRPkBklb5/nmI= |
| MIME-Version | 1.0 |
| In-Reply-To | <BANLkTin5ZQFO-t+r=FNEXAnNh9r6r+iW6A@mail.gmail.com> |
| References | <BANLkTin5ZQFO-t+r=FNEXAnNh9r6r+iW6A@mail.gmail.com> |
| Date | Sun, 10 Apr 2011 19:49:45 -0400 |
| Subject | Re: Python program termination and exception catching |
| From | Jerry Hill <malaclypse2@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.203.1302479386.9059.python-list@python.org> (permalink) |
| Lines | 29 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1302479387 news.xs4all.nl 41102 [::ffff:82.94.164.166]:52767 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:2962 |
Show key headers only | View raw
On Sun, Apr 10, 2011 at 3:25 PM, Jason Swails <jason.swails@gmail.com> wrote: > > Hello everyone, > > This may sound like a bit of a strange desire, but I want to change the way in which a python program quits if an exception is not caught. The program has many different classes of exceptions (for clarity purposes), and they're raised whenever something goes wrong. Most I want to be fatal, but others I'd want to catch and deal with. > > Is there any way to control Python's default exit strategy when it hits an uncaught exception (for instance, call another function that exits "differently")? When an exception is raised and uncaught, the interpreter calls sys.excepthook. You can replace sys.excepthook with your own function. See http://docs.python.org/library/sys.html#sys.excepthook If your program is threaded, you may need to look at this bug: http://bugs.python.org/issue1230540. It describes a problem with replacing sys.excepthook when using the threading module, along with some workarounds. There's a simple example of replacing excepthook here: http://code.activestate.com/recipes/65287/ -- Jerry
Back to comp.lang.python | Previous | Next | Find similar
Re: Python program termination and exception catching Jerry Hill <malaclypse2@gmail.com> - 2011-04-10 19:49 -0400
csiph-web