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 benhoyt
Recipients benhoyt, serhiy.storchaka, vstinner
Date 2016-01-03.01:24:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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)

    with scandir.scandir(path) as it:
        first_entry = next(it)
Date User Action Args
2016-01-03 01:24:47benhoytsetrecipients: + benhoyt, vstinner, serhiy.storchaka
2016-01-03 01:24:46benhoytsetmessageid: <>
2016-01-03 01:24:46benhoytlinkissue25994 messages
2016-01-03 01:24:44benhoytcreate