Skip to content

Commit

Permalink
Simplify patch
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Aug 11, 2024
1 parent 92cc785 commit b8372aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
11 changes: 11 additions & 0 deletions Lib/pathlib/_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,17 @@ def move(self, target):
"""
Recursively move this file or directory tree to the given destination.
"""
self._check_files_differ(target)
try:
return self.replace(target)
except UnsupportedOperation:
pass
except TypeError:
if not isinstance(target, PathBase):
raise
except OSError as err:
if err.errno != errno.EXDEV:
raise
target = self.copy(target, follow_symlinks=False, preserve_metadata=True)
self.delete()
return target
Expand Down
16 changes: 0 additions & 16 deletions Lib/pathlib/_local.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import errno
import io
import ntpath
import operator
Expand Down Expand Up @@ -854,21 +853,6 @@ def onexc(func, filename, err):

delete.avoids_symlink_attacks = shutil.rmtree.avoids_symlink_attacks

def move(self, target):
"""
Recursively move this file or directory tree to the given destination.
"""
self._check_files_differ(target)
try:
return self.replace(target)
except TypeError:
if not isinstance(target, PathBase):
raise
except OSError as err:
if err.errno != errno.EXDEV:
raise
return PathBase.move(self, target)

def rename(self, target):
"""
Rename this path to the target path.
Expand Down

0 comments on commit b8372aa

Please sign in to comment.