Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'handler': 0.05; '(python': 0.07; '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; 'logger': 0.16; 'module).': 0.16; 'nameerror:': 0.16; 'sudo': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'wed,': 0.18; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; '2.2': 0.24; 'instance,': 0.24; 'earlier': 0.24; 'cc:2**0': 0.24; 'logging': 0.26; 'possibly': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'chris': 0.29; 'am,': 0.29; 'said,': 0.30; 'sets': 0.30; "i'm": 0.30; 'work.': 0.31; 'code': 0.31; 'getting': 0.31; "d'aprano": 0.31; 'python2.7': 0.31; 'steven': 0.31; 'file': 0.32; 'running': 0.33; '(most': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'installing': 0.36; 'charset:us- ascii': 0.36; 'should': 0.36; 'message-id:@gmail.com': 0.38; 'jason': 0.38; 'skip:[ 10': 0.38; 'pm,': 0.38; 'recent': 0.39; 'sure': 0.39; 'how': 0.40; 'header:Message-Id:1': 0.63; 'name': 0.63; 'to:addr:gmail.com': 0.65; 'jul': 0.74; "'foo'": 0.84; '2014,': 0.84; 'received:171': 0.84; 'received:stanford.edu': 0.84; 'capture': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=lVC9sYgbD9J2m7PVjLkfAw/4vd7r5WU1eCawhgHXPD8=; b=DyWCad4lAaiKq5a3tR6dBGLTZXXcFozksZcWtWT9nI4qTxoggobjR+z75GIVyXi7G0 /N/IyGThDV641r4+9Ae6QPEW+23fUl2LGc4I0ydOGRbQqHHfNaJ/1liKLICp5K8fCzyP 9nKMRAMhJFVDgs+vGZueRFlwJpu+LCMtIeeY9Ztq2V58N88pL+AOqLZo9UiMoif9CWN4 JrDu0mF9o+tfBOJOTGd2rl70TkmPtia5RIMLbr2uv2wNL/6/Z6ZMHtJvhLlL4SA/Rwm9 uNKS2oRL2xupe7WkjJjxMpIaZNVvy0Le6RByV9JfJtV5+Q8HtCF9WuaepHcWDtB7a2Z0 JOCg== X-Received: by 10.70.92.81 with SMTP id ck17mr5032229pdb.2.1406145769089; Wed, 23 Jul 2014 13:02:49 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: My sys.excepthook dies painfully From: Jason Swails In-Reply-To: Date: Wed, 23 Jul 2014 13:02:51 -0700 Content-Transfer-Encoding: quoted-printable References: <53cf60d3$0$29897$c3e8da3$5496439d@news.astraweb.com> <53cf6867$0$29897$c3e8da3$5496439d@news.astraweb.com> To: Chris Angelico X-Mailer: Apple Mail (2.1878.6) Cc: "python-list@python.org" 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: 54 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1406145777 news.xs4all.nl 2946 [2001:888:2000:d::a6]:55088 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75096 On Jul 23, 2014, at 1:02 AM, Chris Angelico wrote: > 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: >>=20 >>> I have some code which sets up a logger instance, then installs it = as >>> sys.excepthook to capture any uncaught exceptions: >>=20 >> Oh! I should have said, I'm running Python 2.6. >=20 > Ah! I tried it in 2.7 and it seemed to work. One moment... >=20 > 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 >=20 > Still not sure what's going on. Odd. Works for me, too: swails@batman ~ $ python2.6 mylogging.py=20 Traceback (most recent call last): File "mylogging.py", line 24, in foo # Die with uncaught NameError. NameError: name 'foo' is not defined swails@batman ~ $ sudo tail /var/log/messages=20 ... Jul 23 16:02:30 batman INFO:started logging [mylogging] Jul 23 16:02:30 batman INFO:installing error handler [mylogging] Jul 23 16:02:30 batman ERROR:Uncaught : = name 'foo' is not defined [mylogging] I tried it with python2.2 through python2.7 (python 2.2 and earlier did = not have the logging module). I'm not sure how the "mylogger" variable is getting set to None in your = my_error_handler callback, but I don't see how that can possibly be = happening with the provided code... All the best, Jason