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 serhiy.storchaka
Recipients benhoyt, gvanrossum, serhiy.storchaka, vstinner
Date 2016-01-14.22:10:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1452809422.76.0.117373240485.issue26117@psf.upfronthosting.co.za>
In-reply-to
Content
Since scandir iterator has no close method, the most safe way to avoid file descriptors leaks when use os.scandir() is accumulating yielded results into a list before processing them:

    entries = list(os.scandir(path))

But this doesn't save us from all leaks. If an error happened during yielding next entry, opened file descriptor left open.

Proposed patch makes scandir to close the file descriptor not only when an iteration is exhausted, but when any error (expected OSError or MemoryError) is raised.

This is needed to fix possible leaks in os.walk() in 3.5 (see also issue25995).
History
Date User Action Args
2016-01-14 22:10:22serhiy.storchakasetrecipients: + serhiy.storchaka, gvanrossum, vstinner, benhoyt
2016-01-14 22:10:22serhiy.storchakasetmessageid: <1452809422.76.0.117373240485.issue26117@psf.upfronthosting.co.za>
2016-01-14 22:10:22serhiy.storchakalinkissue26117 messages
2016-01-14 22:10:22serhiy.storchakacreate