New submission from Aviv Palivoda: Currently all the stdlib logging handlers (except BufferingHandler) emit method have the following structure: def emit(self, record): try: // do the emit except Exception: self.handleError(record)
I suggest changing this so that the handle method will do the exception handling of the emit: def handle(self, record): rv = self.filter(record) if rv: self.acquire() try: self.emit(record) except Exception: self.handleError(record) finally: self.release() return rv Now the emit() method can be override without the need to handle it's own exceptions. I think this is more clear with the current documentation as well. For example in the handleError function it says that "This method should be called from handlers when an exception is encountered during an emit() call". In addition in the only example that implement the emit() function https://docs.python.org/3/howto/logging-cookbook.html#speaking-logging-messages there is no error handling at all. ---------- components: Library (Lib) files: logging-handle-error.patch keywords: patch messages: 262962 nosy: palaviv, vinay.sajip priority: normal severity: normal status: open title: logging.Handler.handleError should be called from logging.Handler.handle type: behavior versions: Python 3.6 Added file: http://bugs.python.org/file42381/logging-handle-error.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26705> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com