Author catern
Recipients Roman.Evstifeev, catern, miss-islington, vxgmichel
Date 2020-08-29.20:32:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1598733143.71.0.115359278273.issue35409@roundup.psfhosted.org>
In-reply-to
Content
I'm not sure this was the correct fix - or at least, this creates further issues with asynccontextmanager. Consider the following code:

---------------
import contextlib
import types

@contextlib.asynccontextmanager
async def acm():
    # GeneratorExit athrown here from AsyncContextManager __aexit__,
    # propagated from the body of the contextmanager in func()
    yield

@types.coroutine
def _yield():
    yield

async def func():
    async with acm():
        # GeneratorExit raised here
        await _yield()

x = func()
x.send(None) # start running func
x.close() # raise GeneratorExit in func at its current yield
# AsyncContextManager __aexit__ fails with "RuntimeError: generator didn't stop after throw()"
---------------

The reason for the failure in AsyncContextManager __aexit__ is that the asyncgenerator raises StopIteration instead of GeneratorExit when agen.athrow(GeneratorExit()) is called and driven, so "await agen.athrow(GeneratorExit())" just evaluates to None, rather than raising GeneratorExit.

On 3.6 this would work fine, because "await athrow(GeneratorExit())" will raise GeneratorExit. I suspect this was broken by this change.
History
Date User Action Args
2020-08-29 20:32:23caternsetrecipients: + catern, Roman.Evstifeev, vxgmichel, miss-islington
2020-08-29 20:32:23caternsetmessageid: <1598733143.71.0.115359278273.issue35409@roundup.psfhosted.org>
2020-08-29 20:32:23caternlinkissue35409 messages
2020-08-29 20:32:23caterncreate