Message279296
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. |
|
Date |
User |
Action |
Args |
2016-10-24 02:36:51 | walker.hale.iv | set | recipients:
+ walker.hale.iv |
2016-10-24 02:36:51 | walker.hale.iv | set | messageid: <1477276611.77.0.31268131141.issue28516@psf.upfronthosting.co.za> |
2016-10-24 02:36:51 | walker.hale.iv | link | issue28516 messages |
2016-10-24 02:36:50 | walker.hale.iv | create | |
|