Author walker.hale.iv
Recipients walker.hale.iv
Date 2016-10-24.02:36:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1477276611.77.0.31268131141.issue28516@psf.upfronthosting.co.za>
In-reply-to
Content
contextlib.ExitStack implies but does not explicitly state that its __enter__ method trivially returns self.

This means that if a user invokes pop_all and then uses the resulting ExitStack instance in a with statement, the user will be relying on undocumented behavior. Avoiding undocumented behavior forces the user to instead use a tedious try/finally construct, partially defeating the elegance of context managers.

I propose that:

1. The ExitStack.__enter__ method be briefly mentioned as doing nothing besides returning self.

2. The example in pop_all documentation be expanded to show a following with statement that uses the new ExitStack instance.

The discussion in section 29.6.3.2 is not sufficient to make this trivial point clear.
History
Date User Action Args
2016-10-24 02:36:51walker.hale.ivsetrecipients: + walker.hale.iv
2016-10-24 02:36:51walker.hale.ivsetmessageid: <1477276611.77.0.31268131141.issue28516@psf.upfronthosting.co.za>
2016-10-24 02:36:51walker.hale.ivlinkissue28516 messages
2016-10-24 02:36:50walker.hale.ivcreate