Author steven.daprano
Recipients ncoghlan, steven.daprano
Date 2017-06-28.15:48:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1498664911.2.0.271174194344.issue30792@psf.upfronthosting.co.za>
In-reply-to
Content
As discussed on Python-Ideas, there's some interest in a context manager that can convert an exception from one type to another (similarly to the way PEP 479 has StopIteration converted to RuntimeError.

See the thread starting here:
https://mail.python.org/pipermail/python-ideas/2017-June/046109.html

and particularly Nick's comment here:
https://mail.python.org/pipermail/python-ideas/2017-June/046218.html

I've written a recipe on ActiveState:

https://code.activestate.com/recipes/580808-guard-against-an-exception-in-the-wrong-place/

which acts as both a context manager and function decorator. That can be used as proof-of-concept or as a basis for a PR.
History
Date User Action Args
2017-06-28 15:48:31steven.dapranosetrecipients: + steven.daprano, ncoghlan
2017-06-28 15:48:31steven.dapranosetmessageid: <1498664911.2.0.271174194344.issue30792@psf.upfronthosting.co.za>
2017-06-28 15:48:31steven.dapranolinkissue30792 messages
2017-06-28 15:48:30steven.dapranocreate