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
Fix all tests
  • Loading branch information
zmievsa committed Dec 16, 2022
commit 6ec3c3e084151d6923cb45fca401bbd53b07c656
15 changes: 7 additions & 8 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,8 +1283,8 @@ def walk(self, top_down=True, on_error=None, follow_symlinks=False):
stack = deque(((False, self),))

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

Expand All @@ -1294,7 +1294,7 @@ def walk(self, top_down=True, on_error=None, follow_symlinks=False):
# minor reason when (say) a thousand readable directories are still
# left to visit. That logic is copied here.
try:
scandir_it = self._scandir()
scandir_it = top._scandir()
except OSError as error:
if on_error is not None:
on_error(error)
Expand All @@ -1316,15 +1316,14 @@ def walk(self, top_down=True, on_error=None, follow_symlinks=False):
filenames.append(entry.name)

if top_down:
yield top, dirnames, filenames
else:
stack.append((True, (top, dirnames, filenames)))

for dirname in dirnames:
dirpath = self._make_child_relpath(dirname)
for dirname in reversed(dirnames):
Comment thread
barneygale marked this conversation as resolved.
Outdated
dirpath = top._make_child_relpath(dirname)
stack.append((False, dirpath))

if not top_down:
stack.append((True, (top, dirnames, filenames)))


class PosixPath(Path, PurePosixPath):
"""Path subclass for non-Windows systems.
Expand Down