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 njs
Recipients martin.panter, ncoghlan, njs, vstinner, yselivanov
Date 2017-04-01.02:10:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1491012610.15.0.300189604158.issue28629@psf.upfronthosting.co.za>
In-reply-to
Content
It does make sense to skip emitting a warning if there's no try or with block active.

Don't we already have the ability to check for this, though, without any extensions to the frame or code objects? That's what the public PyGen_NeedsFinalizing does, right? It's implemented as a for loop over the frame's block stack, which in most cases should be extremely small, so the performance cost of running this from generator.__del__ seems likely to be minimal.

(I think currently the implementation is not *quite* correct if there's a 'yield from' active – in most cases it won't much matter because if A is yielding from B and A is collected, then B will probably be collected a moment later and have its own __del__ called. But this is not *quite* the same as what should happen, which is that collecting A should immediately call B.close(), which in principle might do something arbitrarily different than B.__del__. But adding a check for whether a 'yield from' is active would be pretty trivial.)
History
Date User Action Args
2017-04-01 02:10:10njssetrecipients: + njs, ncoghlan, vstinner, martin.panter, yselivanov
2017-04-01 02:10:10njssetmessageid: <1491012610.15.0.300189604158.issue28629@psf.upfronthosting.co.za>
2017-04-01 02:10:10njslinkissue28629 messages
2017-04-01 02:10:09njscreate