StreamHandler eating exceptions
The StreamHandler available under the logging package is currently catching all exceptions under the emit() method call. In the Handler.handleError() documentation it's mentioned that it's implemented like that because users do not care about errors in the logging system. I'd like to apply the following patch: Index: Lib/logging/__init__.py =================================================================== --- Lib/logging/__init__.py (revision 41357) +++ Lib/logging/__init__.py (working copy) @@ -738,6 +738,8 @@ except UnicodeError: self.stream.write(fs % msg.encode("UTF-8")) self.flush() + except KeyboardInterrupt: + raise except: self.handleError(record) Anyone against the change? -- Gustavo Niemeyer http://niemeyer.net
Gustavo Niemeyer <gustavo <at> niemeyer.net> writes:
The StreamHandler available under the logging package is currently catching all exceptions under the emit() method call. In the Handler.handleError() documentation it's mentioned that it's implemented like that because users do not care about errors in the logging system.
I'd like to apply the following patch:
[patch snipped]
Anyone against the change?
Good idea. I've checked into svn a patch for both logging/__init__.py and logging/handlers.py which raises both KeyboardInterrupt and SystemExit raised during emit().
I wonder if, once PEP 352 is accepted, this shouldn't be changed so that there is only one except clause instead of two, and it says "except Exception:". This has roughly the same effect as the proposed (and already applied) patch, but does it in a Python-3000-compatible way. ATM it is less robust because it doesn't catch exceptions that don't derive from Exception -- but in all cases where this particular try/except has saved my butt (yes it has! multiple times! :-), the exception thrown was a standard exception. (Did anybody else notice the synchronicity of this request with the PEP 352 discussion?) On 10/31/05, Vinay Sajip <vinay_sajip@yahoo.co.uk> wrote:
Gustavo Niemeyer <gustavo <at> niemeyer.net> writes:
The StreamHandler available under the logging package is currently catching all exceptions under the emit() method call. In the Handler.handleError() documentation it's mentioned that it's implemented like that because users do not care about errors in the logging system.
I'd like to apply the following patch:
[patch snipped]
Anyone against the change?
Good idea. I've checked into svn a patch for both logging/__init__.py and logging/handlers.py which raises both KeyboardInterrupt and SystemExit raised during emit().
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (4)
-
Fred L. Drake, Jr. -
Guido van Rossum -
Gustavo Niemeyer -
Vinay Sajip