Commit 06c45e6e authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #25995: os.walk() no longer uses FDs proportional to the tree depth.

parent 94a619d4
...@@ -369,22 +369,13 @@ def walk(top, topdown=True, onerror=None, followlinks=False): ...@@ -369,22 +369,13 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
# Note that scandir is global in this module due # Note that scandir is global in this module due
# to earlier import-*. # to earlier import-*.
scandir_it = scandir(top) scandir_it = scandir(top)
entries = list(scandir(top))
except OSError as error: except OSError as error:
if onerror is not None: if onerror is not None:
onerror(error) onerror(error)
return return
while True: for entry in entries:
try:
try:
entry = next(scandir_it)
except StopIteration:
break
except OSError as error:
if onerror is not None:
onerror(error)
return
try: try:
is_dir = entry.is_dir() is_dir = entry.is_dir()
except OSError: except OSError:
......
...@@ -73,6 +73,8 @@ Core and Builtins ...@@ -73,6 +73,8 @@ Core and Builtins
Library 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 - Issue #26117: The os.scandir() iterator now closes file descriptor not only
when the iteration is finished, but when it was failed with error. when the iteration is finished, but when it was failed with error.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment