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 mmcewen-g
Recipients gvanrossum, mmcewen-g, pje, rhettinger
Date 2019-11-26.03:32:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1574739164.52.0.211892814458.issue38911@roundup.psfhosted.org>
In-reply-to
Content
My interpretation of issue 24018 was that the Generator ABC was trying to follow the PEP as much as possible, so that users were able to produce a custom generator object and have it behave just like a builtin generator object.

I know that subclassing Generator is unusual; In my case that is a custom object that needs to be an iterator and also enter context managers internally. This seemed to me a very similar problem that the `close` machinery for generators was aimed to address, and subclassing generator worked really nicely, with one exception.

It took me some time to understand why the context managers weren't being exited correctly when the generator was interrupted, and it was because my `close` wasn't being called when the object fell out of scope, as it would have been if my object was a builtin generator object. Manually implementing __del__ fixed this.
History
Date User Action Args
2019-11-26 03:32:44mmcewen-gsetrecipients: + mmcewen-g, gvanrossum, rhettinger, pje
2019-11-26 03:32:44mmcewen-gsetmessageid: <1574739164.52.0.211892814458.issue38911@roundup.psfhosted.org>
2019-11-26 03:32:44mmcewen-glinkissue38911 messages
2019-11-26 03:32:43mmcewen-gcreate