Visitar URL original
gh-89727: Fix os.walk RecursionError on deep trees by jonburdo · Pull Request #99803 · python/cpython · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move os._walk code to os.walk
  • Loading branch information
jonburdo committed Dec 16, 2022
commit 3078ea601feae31baecb36fc2eecfe5e0c19040f
8 changes: 3 additions & 5 deletions Lib/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,11 @@ def walk(top, topdown=True, onerror=None, followlinks=False):

"""
sys.audit("os.walk", top, topdown, onerror, followlinks)
return _walk(fspath(top), topdown, onerror, followlinks)

def _walk(top, topdown, onerror, followlinks):
stack = [(False, top)]
stack = [(False, fspath(top))]
while stack:
is_result, top = stack.pop()
if is_result:
must_yield, top = stack.pop()
if must_yield:
yield top
continue

Expand Down