Author graingert
Recipients graingert, ncoghlan, yselivanov
Date 2021-07-05.09:52:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1625478776.33.0.68470455202.issue44566@roundup.psfhosted.org>
In-reply-to
Content
This is the output:

```
Traceback (most recent call last):
  File "/home/graingert/projects/close.py", line 5, in foo
    yield
  File "/home/graingert/projects/close.py", line 12, in <module>
    raise StartIrritation
__main__.StartIrritation

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/graingert/projects/close.py", line 11, in <module>
    with foo():
  File "/usr/lib/python3.10/contextlib.py", line 151, in __exit__
    self.gen.throw(type, value, traceback)
RuntimeError: generator raised StopIteration
```


Note that this was fixed in @contextlib.asynccontextmanager
```
import asyncio
import contextlib

@contextlib.asynccontextmanager
async def foo():
    yield

class StartIrritation(StopIteration):
    pass


async def amain():
    try:
        async with foo():
            raise StartIrritation
    except StartIrritation:
        print("good")
    except RuntimeError:
        print("bad")

asyncio.run(amain())
```
History
Date User Action Args
2021-07-05 09:52:56graingertsetrecipients: + graingert, ncoghlan, yselivanov
2021-07-05 09:52:56graingertsetmessageid: <1625478776.33.0.68470455202.issue44566@roundup.psfhosted.org>
2021-07-05 09:52:56graingertlinkissue44566 messages
2021-07-05 09:52:56graingertcreate