My sys.excepthook dies painfully

Chris Angelico rosuav at gmail.com
Wed Jul 23 10:02:39 CEST 2014


On Wed, Jul 23, 2014 at 5:46 PM, Steven D'Aprano <steve at pearwood.info> 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 at huix:~$ python mylogging.py
Traceback (most recent call last):
  File "mylogging.py", line 24, in <module>
    foo  # Die with uncaught NameError.
NameError: name 'foo' is not defined
huix at huix:~$ python -V
Python 2.6.6
huix at 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 <type 'exceptions.NameError'>:
name 'foo' is not defined [mylogging]#012None

Still not sure what's going on. Odd.

ChrisA



More information about the Python-list mailing list