Message396983
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())
``` |
|
Date |
User |
Action |
Args |
2021-07-05 09:52:56 | graingert | set | recipients:
+ graingert, ncoghlan, yselivanov |
2021-07-05 09:52:56 | graingert | set | messageid: <1625478776.33.0.68470455202.issue44566@roundup.psfhosted.org> |
2021-07-05 09:52:56 | graingert | link | issue44566 messages |
2021-07-05 09:52:56 | graingert | create | |
|