hongweipeng <hongweichen8...@sina.com> added the comment:
Scandir() will be close when it iteration is over.You can see ScandirIterator_iternext: ``` static PyObject * ScandirIterator_iternext(ScandirIterator *iterator) { while (1) { ... } /* Error or no more files */ ScandirIterator_closedir(iterator); return NULL; } ``` So, `entries = list(scandir(parent_path))` resources in this code can be properly closed. ---------- nosy: +hongweipeng _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37935> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com