[docs] [issue32145] Wrong ExitStack Callback recipe
Nick Coghlan
report at bugs.python.org
Fri Dec 1 00:34:07 EST 2017
Nick Coghlan <ncoghlan at gmail.com> added the comment:
Hmm, I think that may actually qualify as a bug in the `pop_all()` implementation: https://docs.python.org/3/library/contextlib.html#contextlib.ExitStack.pop_all states that it returns an ExitStack instance, not an instance of the current type.
For 3.6 (and hence the online docs), we can fix the recipe to allow for `callback=None` (with the expectation that the callback will be added afterwards).
Barry, I'd be interested in your thoughts on what to do for 3.7+ - we can either leave the current behaviour alone, and amend the documentation, or else change the code to call ExitStack directly, rather than type(self).
I'm leaning towards only changing the docs as being lower risk - folks may be relying on the current behaviour, so changing it may break their code, whereas changing the docs doesn't risk breaking anything.
----------
nosy: +barry
versions: +Python 3.7 -Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32145>
_______________________________________
More information about the docs
mailing list