This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author barry
Recipients Denaun, barry, docs@python, ncoghlan
Date 2017-12-26.16:58:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <57C412E0-BCE9-4721-91DE-ABAD44040E2F@python.org>
In-reply-to <1514245910.29.0.213398074469.issue32145@psf.upfronthosting.co.za>
Content
On Dec 25, 2017, at 18:51, Nick Coghlan <report@bugs.python.org> wrote:
> 
> 3. A for-subclasses-only "self._clone()" API could work as follows:
> 
>    def _clone(self, new_instance=None):
>        if new_instance is None:
>            new_instance = type(self)()
>        # Clone state here
>        return new_instance
> 
> Then subclasses could override *just* the instance creation part by doing:
> 
>    def _clone(self):
>        return super()._clone(self._make_instance())
> 
> While also being free to add their own additional state copying code if needed.

So _make_instance() wouldn’t be part of ExitStack’s API, but subclasses could implement it (and name it whatever they want of course)?

I’m not sure _clone() is the right name here since that implies to me state copy as well, and I totally agree with your other points.  That’s why I originally suggested _make_instance() would be the name and API in the base class.
History
Date User Action Args
2017-12-26 16:58:39barrysetrecipients: + barry, ncoghlan, docs@python, Denaun
2017-12-26 16:58:39barrylinkissue32145 messages
2017-12-26 16:58:39barrycreate