Message280728
| 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:56 | martin.panter | set | recipients:
+ martin.panter, ncoghlan, vstinner, njs, yselivanov |
| 2016年11月14日 03:10:56 | martin.panter | set | messageid: <1479093056.25.0.977008903733.issue28629@psf.upfronthosting.co.za> |
| 2016年11月14日 03:10:56 | martin.panter | link | issue28629 messages |
| 2016年11月14日 03:10:55 | martin.panter | create |
|