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: Use "raise from None"
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: josh.r, serhiy.storchaka
Priority: normal Keywords:

Created on 2017-03-08 21:14 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 569 merged serhiy.storchaka, 2017-03-08 21:19
PR 3978 merged pablogsal, 2017-10-12 21:02
Messages (5)
msg289258 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-08 21:14
Sometimes after catching some exception the new exception of more appropriate type and with more appropriate message is raised. The initial exception often is not relevant to the final exception, it is raised only due to using EAFP rather than LBYL. It should be excluded from the traceback by using "raise from None". This idiom is often used. Following PR makes it be used in more cases.
msg289266 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2017-03-09 02:38
To tie the exceptions to the actual line, would it perhaps make sense to copy over the traceback of the original exception using .with_traceback?
msg289267 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2017-03-09 02:39
Particularly when the type of the exception isn't being changed, it's only altering the message to provide more information?
msg289274 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-09 05:51
I don't think this is needed. The traceback points to the actual line -- the line with the "raise" statement.
msg291161 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-04-05 06:37
New changeset 5affd23e6f42125998724787025080a24839266e by Serhiy Storchaka in branch 'master':
bpo-29762: More use "raise from None". (#569)
https://github.com/python/cpython/commit/5affd23e6f42125998724787025080a24839266e
History
Date User Action Args
2022-04-11 14:58:44adminsetgithub: 73948
2017-10-12 21:02:42pablogsalsetpull_requests: + pull_request3954
2017-04-05 06:39:04serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-04-05 06:37:26serhiy.storchakasetmessages: + msg291161
2017-03-09 05:51:58serhiy.storchakasetmessages: + msg289274
2017-03-09 02:39:42josh.rsetmessages: + msg289267
2017-03-09 02:38:50josh.rsetnosy: + josh.r
messages: + msg289266
2017-03-08 21:19:15serhiy.storchakasetpull_requests: + pull_request465
2017-03-08 21:14:36serhiy.storchakacreate