Skip to content

Commit 5934ba1

Browse files
committed
Duck-type the _copy_writer
1 parent e13ed9c commit 5934ba1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Lib/pathlib/_abc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ def copy(self, target, follow_symlinks=True, dirs_exist_ok=False,
561561
"""
562562
Recursively copy this file or directory tree to the given destination.
563563
"""
564-
if not isinstance(target, ReadablePath):
564+
if not hasattr(target, '_copy_writer'):
565565
target = self.with_segments(target)
566566

567567
# Delegate to the target path's CopyWriter object.
@@ -579,7 +579,7 @@ def copy_into(self, target_dir, *, follow_symlinks=True,
579579
name = self.name
580580
if not name:
581581
raise ValueError(f"{self!r} has an empty name")
582-
elif isinstance(target_dir, ReadablePath):
582+
elif hasattr(target_dir, '_copy_writer'):
583583
target = target_dir / name
584584
else:
585585
target = self.with_segments(target_dir, name)

Lib/pathlib/_local.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ def move(self, target):
11661166
except TypeError:
11671167
pass
11681168
else:
1169-
if not isinstance(target, WritablePath):
1169+
if not hasattr(target, '_copy_writer'):
11701170
target = self.with_segments(target_str)
11711171
target._copy_writer._ensure_different_file(self)
11721172
try:
@@ -1187,7 +1187,7 @@ def move_into(self, target_dir):
11871187
name = self.name
11881188
if not name:
11891189
raise ValueError(f"{self!r} has an empty name")
1190-
elif isinstance(target_dir, WritablePath):
1190+
elif hasattr(target_dir, '_copy_writer'):
11911191
target = target_dir / name
11921192
else:
11931193
target = self.with_segments(target_dir, name)

0 commit comments

Comments
 (0)