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 martin.panter
Recipients martin.panter, ncoghlan, njs, vstinner, yselivanov
Date 2016-11-14.03:10:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1479093056.25.0.977008903733.issue28629@psf.upfronthosting.co.za>
In-reply-to
Content
This would be hard to get right, but maybe not impossible. If the frame is suspended, and will do special handling of GeneratorExit, a ResourceWarning would be nice in most cases. But if the frame will not catch any exception, there should be no ResourceWarning. I think this is the big difference between mygen() and Victor’s generator expression:

gen = (2**i for i in itertools.count())
next(gen)  # Generator suspended but won’t catch any exception
del gen  # Like deleting a plain iterator; no ResourceWarning expected

One more complication: If the frame is suspended at something like “yield from open(fname)”, it should trigger a ResourceWarning, because GeneratorExit would cause the file’s close() method to be called. But if “yield from” is calling a simpler generator-iterator with nothing to clean up, it should not emit a ResourceWarning.
History
Date User Action Args
2016-11-14 03:10:56martin.pantersetrecipients: + martin.panter, ncoghlan, vstinner, njs, yselivanov
2016-11-14 03:10:56martin.pantersetmessageid: <1479093056.25.0.977008903733.issue28629@psf.upfronthosting.co.za>
2016-11-14 03:10:56martin.panterlinkissue28629 messages
2016-11-14 03:10:55martin.pantercreate