PEP 707: A simplified signature for __exit__ and __aexit__

A datapoint for support of the idea to revamp the context manager protocol is the discussion in Yield-based contextmanager for classes, and especially the quote from @njs

So new users constantly try to write their own __enter__ /__exit__ methods […] and I think literally every person who’s ever tried this has gotten it wrong (mostly around exception handling details). At this point we don’t even try to debug; we just tell users to always use @contextmanager.

1 Like