I just noticed that StreamHandler contains the following fragment in its emit() method: try: except (KeyboardInterrupt, SystemExit): #pragma: no cover raise except: self.handleError(record) Couldn't this be simplified to the following? try: except Exception: self.handleError(record) I.e. instead of manually catching and re-raising a few BaseExceptions, just don't catch anything that derives from BaseException but not from Exception? (I noticed because we have an internal clone of this class that occasionally gets augmented with yet another base exception that shouldn't be handled.
> Couldn't this be simplified to the following? I think this is idiomatic now (since 2.5). There are some places where similar outdated code used. See the attached patch. There are more dubious places in Lib/multiprocessing/managers.py and Lib/asyncore.py.
assignee: vinay.sajip -> title: Possible simplification for logging.StreamHandler exception handling -> Possible simplification for old-style exception handling code in stdlib