Andreas Stührk <andy-pyt...@hammerhartes.de> added the comment:

I really doubt that this issue has anything to do with `sys.excepthook` at all. 
It's rather that module members are set to `None` during module cleanup. 
Because the module raises an exception when one tries to import it, it will be 
cleaned up immediately (see `PyImport_ExecCodeModuleEx`: it calls 
`remove_module` which will call at some point `_PyModule_Clear`). At the time 
when `sys.excepthook` is called, all module members are already set to `None`.

One can easily demonstrate that this is really the problem by removing the 
exception raise in your example code: If one then imports "loggingTest" in an 
interactive session and raises an exception, the expected behaviour can be 
observed.

Another workaround is to bind `logger` as a default argument (i.e. ``def 
handleException(excType, excValue, traceback, logger=logger):``).

----------
nosy: +Trundle

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11705>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to