# Note that scandir is global in this module due
# to earlier import-*.
scandir_it = scandir(top)
+ entries = list(scandir(top))
except OSError as error:
if onerror is not None:
onerror(error)
return
- while True:
- try:
- try:
- entry = next(scandir_it)
- except StopIteration:
- break
- except OSError as error:
- if onerror is not None:
- onerror(error)
- return
-
+ for entry in entries:
try:
is_dir = entry.is_dir()
except OSError:
Library
-------
+- Issue #25995: os.walk() no longer uses FDs proportional to the tree depth.
+
- Issue #26117: The os.scandir() iterator now closes file descriptor not only
when the iteration is finished, but when it was failed with error.