[issue30792] Add contextlib.convert_exception manager

2017-06-28 Thread Nick Coghlan
Nick Coghlan added the comment: Also clarifying a point that came up later in the thread [1]: one of the motivating examples that came up in the thread was the idea of using this to catch AttributeError exceptions in property and __getattr__ implementations and convert them to RuntimeError.

[issue30792] Add contextlib.convert_exception manager

2017-06-28 Thread Steven D'Aprano
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: