8000 GH-132566: Progressively delete files in `pathlib.Path.move()` by barneygale · Pull Request #133852 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-132566: Progressively delete files in pathlib.Path.move() #133852

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Swap tuple order
  • Loading branch information
barneygale committed May 10, 2025
commit 2be822db7b49a8e09188741641c1dabca146865d
6 changes: 3 additions & 3 deletions Lib/pathlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ def _iter_copy_from(self, source, follow_symlinks=True,
preserve_metadata=False):
"""
Recursively copy the given path to t 8000 his path. Yields a
(target, source) tuple after each path is copied.
(source, target) tuple after each path is copied.
"""
if not follow_symlinks and source.info.is_symlink():
self._copy_from_symlink(source, preserve_metadata)
Expand All @@ -1128,7 +1128,7 @@ def _iter_copy_from(self, source, follow_symlinks=True,
copy_info(source.info, self)
else:
self._copy_from_file(source, preserve_metadata)
yield self, source
yield source, self

def _copy_from_file(self, source, preserve_metadata=False):
ensure_different_files(source, self)
Expand Down Expand Up @@ -1186,7 +1186,7 @@ def move(self, target):

# Fall back to copy+delete.
ensure_distinct_paths(self, target)
for _dst, src in target._iter_copy_from(self, follow_symlinks=False, preserve_metadata=True):
for src, _dst in target._iter_copy_from(self, follow_symlinks=False, preserve_metadata=True):
if src.info.is_symlink() or src.is_junction():
src.unlink()
elif src.info.is_dir():
Expand Down
4 changes: 2 additions & 2 deletions Lib/pathlib/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def write_text(self, data, encoding=None, errors=None, newline=None):
def _iter_copy_from(self, source, follow_symlinks=True):
"""
Recursively copy the given path to this path. Yields a
(target, source) tuple after each path is copied.
(source, target) tuple after each path is copied.
"""
if not follow_symlinks and source.info.is_symlink():
self.symlink_to(str(source.readlink()), source.info.is_dir())
Expand All @@ -423,7 +423,7 @@ def _iter_copy_from(self, source, follow_symlinks=True):
with magic_open(source, 'rb') as source_f:
with magic_open(self, 'wb') as target_f:
copyfileobj(source_f, target_f)
yield self, source
yield source, self


_JoinablePath.register(PurePath)
Expand Down
Loading
0