This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vinay.sajip
Recipients
Date 2006-12-22.07:42:40
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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?
History
Date User Action Args
2007-08-23 13:53:44adminlinkissue411881 messages
2007-08-23 13:53:44admincreate