Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'handler': 0.05; 'error:': 0.07; 'subject:skip:s 10': 0.07; 'seemed': 0.09; 'skip:/ 10': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '2.7': 0.14; '23,': 0.16; '24,': 0.16; 'ah!': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'logger': 0.16; 'nameerror:': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'cc:addr:python.org': 0.22; 'error': 0.23; 'instance,': 0.24; 'cc:2**0': 0.24; 'logging': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'said,': 0.30; 'sets': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'work.': 0.31; 'code': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'file': 0.32; 'running': 0.33; '(most': 0.33; 'received:google.com': 0.35; 'installing': 0.36; 'should': 0.36; 'skip:[ 10': 0.38; 'pm,': 0.38; 'recent': 0.39; 'sure': 0.39; 'name': 0.63; 'jul': 0.74; "'foo'": 0.84; 'capture': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=MpleHruovT2tZ4VIf/muRQROQHJS33dn07p2FpMzkc4=; b=pFgaNcAIEmwE6K17fdbVTci5NE1XXtmrwcyglr3Y0lDjInlzGEczgY+Gz7aPvglIrR KRzE+TisOpniVqos/yruLWV92j0nfJI3X4htiSUiJ6VF4D8nPcBdEej2sF08iPURvuq/ GMSpKz+G8JRhgIRjqsRnLj6E7Xn8pDLrio8F4dXxMyS5Dd/VUZV2StB2bW/EpqMBRslL PSux2AgAkZJ3ljToJsuNK+z03MiNZbU8woWZwAq+0HY+hNq38aHkJDkmeYzM2p1ihsiX VeNnxSbf97nAC2tRDqZ7Q4WM4Bv78ji9BUw3lDmclN4m8rFilANJZQ/UX3MFVh7Z90V+ mlhQ== MIME-Version: 1.0 X-Received: by 10.220.195.67 with SMTP id eb3mr48047900vcb.30.1406102559895; Wed, 23 Jul 2014 01:02:39 -0700 (PDT) In-Reply-To: <53cf6867$0$29897$c3e8da3$5496439d@news.astraweb.com> References: <53cf60d3$0$29897$c3e8da3$5496439d@news.astraweb.com> <53cf6867$0$29897$c3e8da3$5496439d@news.astraweb.com> Date: Wed, 23 Jul 2014 18:02:39 +1000 Subject: Re: My sys.excepthook dies painfully From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1406102562 news.xs4all.nl 2958 [2001:888:2000:d::a6]:57677 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75069 On Wed, Jul 23, 2014 at 5:46 PM, Steven D'Aprano wrote: > On Wed, 23 Jul 2014 07:14:27 +0000, Steven D'Aprano wrote: > >> I have some code which sets up a logger instance, then installs it as >> sys.excepthook to capture any uncaught exceptions: > > Oh! I should have said, I'm running Python 2.6. Ah! I tried it in 2.7 and it seemed to work. One moment... huix@huix:~$ python mylogging.py Traceback (most recent call last): File "mylogging.py", line 24, in foo # Die with uncaught NameError. NameError: name 'foo' is not defined huix@huix:~$ python -V Python 2.6.6 huix@huix:~$ tail /var/log/syslog ... Jul 23 18:01:49 huix INFO: started logging [mylogging] Jul 23 18:01:49 huix INFO: installing error handler [mylogging] Jul 23 18:01:49 huix ERROR: Uncaught : name 'foo' is not defined [mylogging]#012None Still not sure what's going on. Odd. ChrisA