Message258232
| 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:22 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, gvanrossum, vstinner, benhoyt |
| 2016年01月14日 22:10:22 | serhiy.storchaka | set | messageid: <1452809422.76.0.117373240485.issue26117@psf.upfronthosting.co.za> |
| 2016年01月14日 22:10:22 | serhiy.storchaka | link | issue26117 messages |
| 2016年01月14日 22:10:22 | serhiy.storchaka | create |
|