On Jul 23, 2014, at 1:02 AM, Chris Angelico <ros...@gmail.com> wrote:

> On Wed, Jul 23, 2014 at 5:46 PM, Steven D'Aprano <st...@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@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@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 <type 'exceptions.NameError'>:
> name 'foo' is not defined [mylogging]#012None
> 
> Still not sure what's going on. Odd.

Works for me, too:

swails@batman ~ $ python2.6 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
swails@batman ~ $ sudo tail /var/log/messages 
...
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 <type 'exceptions.NameError'>: 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
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to