-
- Notifications
You must be signed in to change notification settings - Fork 33.1k
Closed
Labels
Description
import contextlib @contextlib.asynccontextmanager async def f(): try: yield finally: pass async def amain(): async with f(): 1/0 with contextlib.closing(amain().__await__()) as gen: next(gen, None)
Traceback (most recent call last): File "/home/graingert/projects/cpython/demo.py", line 16, in <module> next(gen, None) File "/usr/lib/python3.11/contextlib.py", line 222, in __aexit__ await self.gen.athrow(typ, value, traceback) File "/home/graingert/projects/cpython/demo.py", line 7, in f yield File "/home/graingert/projects/cpython/demo.py", line 12, in amain async with f(): 1/0 ~^~ ZeroDivisionError: division by zero
Originally posted by @graingert in #92118 (comment)
Linked PRs
- gh-95882: fix regression in the traceback of exceptions propagated from inside a contextlib context manager #95883
- [3.10] gh-95882: Add tests for traceback from contextlib context managers (GH-95883) #100715
- [3.11] gh-95882: fix regression in the traceback of exceptions propagated from inside a contextlib context manager (GH-95883) #100718