Message4097
The reason for the fair number of bare excepts in logging is this: in many cases (e.g. long-running processes like Zope servers) users don't want their application to change behaviour just because of some exception thrown in logging. So, logging aims to be very quiet indeed and swallows exceptions, except SystemExit and KeyboardInterrupt in certain situations.
Also, logging is one of the modules which is (meant to be) 1.5.2 compatible, and string exceptions are not that uncommon in older code.
I've looked at bare excepts in logging and here's my summary on them:
logging/__init__.py:
====================
currentframe(): Backward compatibility only, sys._getframe is used where available so currentframe() will only be called on rare occasions.
LogRecord.__init__(): There's a try/bare except around calls to os.path.basename() and os.path.splitext(). I could add a raise clause for SystemExit/KeyboardInterrupt.
StreamHandler.emit(): Reraises SystemExit and KeyboardInterrupt, and otherwise calls handleError() which raises everything if raiseExceptions is set (the default).
shutdown(): Normally only called at system exit, and will re-raise everything if raiseExceptions is set (the default).
logging/handlers.py:
====================
BaseRotatingHandler.emit(): Reraises SystemExit and KeyboardInterrupt, and otherwise calls handleError() which raises everything if raiseExceptions is set (the default).
SocketHandler.createSocket(): I could add a raise clause for SystemExit/KeyboardInterrupt.
SocketHandler.emit(): Reraises SystemExit and KeyboardInterrupt, and otherwise calls handleError() which raises everything if raiseExceptions is set (the default).
SysLogHandler.emit(): Reraises SystemExit and KeyboardInterrupt, and otherwise calls handleError() which raises everything if raiseExceptions is set (the default).
SMTPHandler.emit(): Should change bare except to ImportError for the formatdate import.
Elsewhere, reraises SystemExit and KeyboardInterrupt, and otherwise calls handleError() which raises everything if raiseExceptions is set (the default).
NTEventLogHandler.emit(): Reraises SystemExit and KeyboardInterrupt, and otherwise calls handleError() which raises everything if raiseExceptions is set (the default).
HTTPHandler.emit(): Reraises SystemExit and KeyboardInterrupt, and otherwise calls handleError() which raises everything if raiseExceptions is set (the default).
logging/config.py:
====================
listen.ConfigStreamHandler.handle(): Reraises SystemExit and KeyboardInterrupt, prints everything else and continues - seems OK for a long-running thread.
What do you think?
|
|
Date |
User |
Action |
Args |
2007-08-23 13:53:44 | admin | link | issue411881 messages |
2007-08-23 13:53:44 | admin | create | |
|