New submission from John Belmonte <j...@neggie.net>:
Over at the Trio project, we have evidence that `AsyncExitStack.enter_async_context(foo())` is not actually equivalent to `async with foo()` regarding raised exception context. The symptom is a very long, unhelpful tracebacks because the __context__ of raised exceptions is not set to the expected object. https://github.com/python-trio/trio/issues/2001 I can't speak to this solution myself, but njsmith suggests this amendment to contextlib: saved_context = exc_details[1].__context__ try: raise exc_details[1] finally: exc_details[1].__context__ = saved_context ---------- components: Library (Lib) messages: 397230 nosy: John Belmonte, njs priority: normal severity: normal status: open title: AsyncExitStack.enter_async_context() is mishandling exception __context__ _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44594> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com