[docs] [issue32145] Wrong ExitStack Callback recipe
Barry A. Warsaw
report at bugs.python.org
Sun Dec 10 19:54:15 EST 2017
Barry A. Warsaw <barry at python.org> added the comment:
I wasn't even aware that pop_all() tries to create the concrete subtype. I wonder how common subclassing ExitStack is in practice. (Of course, the answer is that we'll never know.)
For 3.7, we should probably delegate instance creation to a new non-private method, e.g.
new_stack = self._make_instance()
so *if* you subclass, you can create the new ExitStack subclass instances any way you want. I would then change the default implementation to make an ExitStack() explicitly, as per the current documentation.
+1 for fixing the recipe and not changing the code for 3.6. You might want to add a note describing the current behavior for <= 3.6 and indicating that this will change for 3.7+
Finally, while you're at it, is there any reason not to change the recipe to use:
super().__init__()
instead?
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32145>
_______________________________________
More information about the docs
mailing list