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 njs
Recipients John Belmonte, asvetlov, ncoghlan, njs, xtreak, yselivanov
Date 2019-08-09.20:18:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1565381899.28.0.872734763284.issue37398@roundup.psfhosted.org>
In-reply-to
Content
> I wouldn't be OK with magic switching in the behaviour of ContextDecorator (that's not only semantically confusing, it's also going to make the contextlib function wrappers even slower than they already are).

I hear you on the semantic confusion, but is a single check at definition time really that expensive? The runtime cost is zero.

> I'm also entirely unclear on what you would expect a synchronous context manager to do when applied to an asynchronous function, as embedding an "await" call inside a synchronous with statement is unlikely to end well.

It would be like:

async def blah():
    with something():
        await foo()

There's nothing weird about this; people write the long version all the time. You'd only do it when 'something()' doesn't do I/O, but there are lots of context managers that don't do I/O.
History
Date User Action Args
2019-08-09 20:18:19njssetrecipients: + njs, ncoghlan, asvetlov, yselivanov, xtreak, John Belmonte
2019-08-09 20:18:19njssetmessageid: <1565381899.28.0.872734763284.issue37398@roundup.psfhosted.org>
2019-08-09 20:18:19njslinkissue37398 messages
2019-08-09 20:18:18njscreate