8000 gh-89727: Fix pathlib.Path.walk RecursionError on deep trees by zmievsa · Pull Request #100282 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-89727: Fix pathlib.Path.walk RecursionError on deep trees #100282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
Make everything consistent with os.walk
  • Loading branch information
zmievsa committed Dec 17, 2022
commit 20476ffca31adb6586a6d4dd9f98c564562f4fd5
6 changes: 3 additions & 3 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1280,11 +1280,11 @@ def expanduser(self):
def walk(self, top_down=True, on_error=None, follow_symlinks=False):
"""Walk the directory tree from this directory, similar to os.walk()."""
sys.audit("pathlib.Path.walk", self, on_error, follow_symlinks)
stack = deque(((False, self),))
stack = [(False, self)]

while stack:
must_be_yielded_immediately, top = stack.pop()
if must_be_yielded_immediately:
must_yield, top = stack.pop()
if must_yield:
yield top
continue

Expand Down
0