Message257391
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) |
|
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 | |
|