This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Dima.Tisnek
Recipients Dima.Tisnek, asvetlov, yselivanov
Date 2021-12-06.13:24:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1638797059.87.0.372415243632.issue45996@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-12-06 13:24:20Dima.Tisneksetrecipients: + Dima.Tisnek, asvetlov, yselivanov
2021-12-06 13:24:19Dima.Tisneksetmessageid: <1638797059.87.0.372415243632.issue45996@roundup.psfhosted.org>
2021-12-06 13:24:19Dima.Tisneklinkissue45996 messages
2021-12-06 13:24:19Dima.Tisnekcreate