Skip to content

Commit b8372aa

Browse files
committed
Simplify patch
1 parent 92cc785 commit b8372aa

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

Lib/pathlib/_abc.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,17 @@ def move(self, target):
927927
"""
928928
Recursively move this file or directory tree to the given destination.
929929
"""
930+
self._check_files_differ(target)
931+
try:
932+
return self.replace(target)
933+
except UnsupportedOperation:
934+
pass
935+
except TypeError:
936+
if not isinstance(target, PathBase):
937+
raise
938+
except OSError as err:
939+
if err.errno != errno.EXDEV:
940+
raise
930941
target = self.copy(target, follow_symlinks=False, preserve_metadata=True)
931942
self.delete()
932943
return target

Lib/pathlib/_local.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import errno
21
import io
32
import ntpath
43
import operator
@@ -854,21 +853,6 @@ def onexc(func, filename, err):
854853

855854
delete.avoids_symlink_attacks = shutil.rmtree.avoids_symlink_attacks
856855

857-
def move(self, target):
858-
"""
859-
Recursively move this file or directory tree to the given destination.
860-
"""
861-
self._check_files_differ(target)
862-
try:
863-
return self.replace(target)
864-
except TypeError:
865-
if not isinstance(target, PathBase):
866-
raise
867-
except OSError as err:
868-
if err.errno != errno.EXDEV:
869-
raise
870-
return PathBase.move(self, target)
871-
872856
def rename(self, target):
873857
"""
874858
Rename this path to the target path.

0 commit comments

Comments
 (0)