mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #25995: os.walk() no longer uses FDs proportional to the tree depth.
This commit is contained in:
parent
94a619d48b
commit
06c45e6e9c
2 changed files with 4 additions and 11 deletions
13
Lib/os.py
13
Lib/os.py
|
@ -369,22 +369,13 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
|
|||
# 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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue