Message257391
| Author |
benhoyt |
| Recipients |
benhoyt, serhiy.storchaka, vstinner |
| Date |
2016年01月03日.01:24:44 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1451784286.68.0.221590675984.issue25994@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I'm not sure this is actually a leak, because (looking at the code) ScandirIterator_close() is called not just in the destructor, but also at the end of iterating, just before raising StopIteration. Is the issue that if an exception is raised or you stop iterating before the end, then it's less determined when the destructor/close is called?
I think we could fairly easily add an explicit close method to the iterator and make it a context manager (add __enter__ and __exit__ methods to the iterator). Is this what you're thinking of:
# manual close
it = scandir.scandir(path)
first_entry = next(it)
it.close()
with scandir.scandir(path) as it:
first_entry = next(it) |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2016年01月03日 01:24:47 | benhoyt | set | recipients:
+ benhoyt, vstinner, serhiy.storchaka |
| 2016年01月03日 01:24:46 | benhoyt | set | messageid: <1451784286.68.0.221590675984.issue25994@psf.upfronthosting.co.za> |
| 2016年01月03日 01:24:46 | benhoyt | link | issue25994 messages |
| 2016年01月03日 01:24:44 | benhoyt | create |
|