New submission from Steven D'Aprano: 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. ---------- components: Library (Lib) messages: 297193 nosy: ncoghlan, steven.daprano priority: normal severity: normal status: open title: Add contextlib.convert_exception manager type: enhancement versions: Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30792> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com