Message407799
Consider this illegal code:
import logging
from asyncio import sleep, gather, run
from contextlib import asynccontextmanager
@asynccontextmanager
async def foo():
await sleep(1)
yield
async def test():
f = foo()
await gather(f.__aenter__(), f.__aenter__())
run(test())
If it's ran with Python 3.9, user gets a sensible error:
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 175, in __aenter__
return await self.gen.__anext__()
RuntimeError: anext(): asynchronous generator is already running
However, if it's ran with Python 3.10, user gets a cryptic error:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py", line 197, in __aenter__
del self.args, self.kwds, self.func
AttributeError: args
Which makes it harder to pinpoint what's wrong when the stack is complex.
I've hit this with fastapi/starlette/mangum combo and a custom middleware. |
|
Date |
User |
Action |
Args |
2021-12-06 13:24:20 | Dima.Tisnek | set | recipients:
+ Dima.Tisnek, asvetlov, yselivanov |
2021-12-06 13:24:19 | Dima.Tisnek | set | messageid: <1638797059.87.0.372415243632.issue45996@roundup.psfhosted.org> |
2021-12-06 13:24:19 | Dima.Tisnek | link | issue45996 messages |
2021-12-06 13:24:19 | Dima.Tisnek | create | |
|