Title: Possible simplification for old-style exception handling code in stdlib
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, python-dev, r.david.murray, ronaldoussoren, serhiy.storchaka, vinay.sajip
Priority: normal Keywords: patch

Created on 2012-10-05 14:46 by gvanrossum, last changed 2013-05-01 13:46 by r.david.murray. This issue is now closed.

File name Uploaded Description Edit
reraise_keyboard_interrupt.patch serhiy.storchaka, 2012-10-05 17:41 review
Messages (5)
msg172087 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2012-10-05 14:46
I just noticed that StreamHandler contains the following fragment in its emit() method:

    <do some writing>
  except (KeyboardInterrupt, SystemExit): #pragma: no cover                

Couldn't this be simplified to the following?

    <do some writing>
  except Exception:

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.
msg172104 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-10-05 17:41
> 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/ and Lib/
msg172452 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-10-09 07:06
New changeset 46889b772442 by Vinay Sajip in branch 'default':
Issue #16141: replaced old-style exception handling code in logging with the modern idiom.
msg188212 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2013-05-01 11:58
Shouldn't this issue be closed? (the proposed patch was applied in Oct. last year)
msg188225 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-05-01 13:46
I'm guessing Serhiy left it open because of the question about multiprocessing and asyncore.  Given that he rated them as dubious, let's just close it.
Date User Action Args
2013-05-01 13:46:54r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg188225

resolution: fixed
stage: patch review -> resolved
2013-05-01 11:58:31ronaldoussorensetnosy: + ronaldoussoren
messages: + msg188212
2012-10-09 07:08:59vinay.sajipsetassignee: vinay.sajip ->
title: Possible simplification for logging.StreamHandler exception handling -> Possible simplification for old-style exception handling code in stdlib
2012-10-09 07:06:25python-devsetnosy: + python-dev
messages: + msg172452
2012-10-08 23:13:19vinay.sajipsetassignee: vinay.sajip
2012-10-05 18:13:30pitrousetnosy: + vinay.sajip

stage: patch review
2012-10-05 17:41:40serhiy.storchakasetfiles: + reraise_keyboard_interrupt.patch

nosy: + serhiy.storchaka
messages: + msg172104

keywords: + patch
2012-10-05 14:46:26gvanrossumcreate