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.

classification
Title: Eliminate do-nothing exception handlers
Type: enhancement Stage: resolved
Components: Distutils, IDLE, Library (Lib), Tests, Tkinter Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: dstufft, eric.araujo, martin.panter, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2015-05-20 05:48 by martin.panter, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
reraise.patch martin.panter, 2015-05-20 05:48 review
Messages (4)
msg243645 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-05-20 05:48
These changes remove exception handlers that simply reraise the exception. They are not needed because either they are at the end of the exception handler list, or the exception being reraised would not be caught by any other handler (e.g. no need to reraise SystemExit if you are only interested in Exception). I think they make the code more confusing to read.

I noticed the tkinter/font.py dead code when reading the code, Victor Stinner pointed out the distutils case in Issue 21259, and I found the rest by searching for similar cases.

 Lib/distutils/core.py        |   2 --
 Lib/idlelib/idle.pyw         |  26 +++++++++++---------------
 Lib/idlelib/rpc.py           |   5 +----
 Lib/test/regrtest.py         |   4 ----
 Lib/test/test_queue.py       |  10 +++-------
 Lib/test/test_urllib2net.py  |   2 --
 Lib/tkinter/font.py          |   2 --
 Lib/unittest/test/support.py |   4 ----
msg243653 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-05-20 08:09
Changes look mostly good, but IDLE changes should be applied to all versions and the code in test_queue.py is dim.
msg243657 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-05-20 13:15
New changeset 004c689d259c by Serhiy Storchaka in branch 'default':
Issue #24245: Eliminated senseless expect clauses that have no any effect.
https://hg.python.org/cpython/rev/004c689d259c

New changeset 56e1d24806b3 by Serhiy Storchaka in branch '2.7':
Issue #24245: Eliminated senseless expect clauses that have no any effect in
https://hg.python.org/cpython/rev/56e1d24806b3

New changeset f10ba5313fbb by Serhiy Storchaka in branch '3.4':
Issue #24245: Eliminated senseless expect clauses that have no any effect in
https://hg.python.org/cpython/rev/f10ba5313fbb

New changeset 5deb169ebb22 by Serhiy Storchaka in branch 'default':
Issue #24245: Eliminated senseless expect clauses that have no any effect in
https://hg.python.org/cpython/rev/5deb169ebb22
msg243659 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-05-20 13:19
Committed all changes except test_queue.py. Looks as this file is worth separate issue for refactoring. For example asserRaises() can be used in multiple places instead of try/fail/except idiom. May be there is other non-idiomatic code.
History
Date User Action Args
2022-04-11 14:58:17adminsetgithub: 68433
2015-05-20 13:19:58serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg243659

stage: patch review -> resolved
2015-05-20 13:15:52python-devsetnosy: + python-dev
messages: + msg243657
2015-05-20 08:09:54serhiy.storchakasetmessages: + msg243653
2015-05-20 07:40:22serhiy.storchakasetassignee: serhiy.storchaka

nosy: + serhiy.storchaka
2015-05-20 05:48:18martin.pantercreate