8000 GH-128520: pathlib ABCs: tighten up argument types by barneygale · Pull Request #131621 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-128520: pathlib ABCs: tighten up argument types #131621

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

Merged
merged 3 commits into from
Mar 24, 2025
Merged
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
Drop handling for missing _copy_from().
  • Loading branch information
barneygale committed Mar 23, 2025
commit 80cc9c2296e10ac786732829c652a4b93044142b
6 changes: 1 addition & 5 deletions Lib/pathlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,11 +1105,7 @@ def copy(self, target, **kwargs):
if not hasattr(target, 'with_segments'):
target = self.with_segments(target)
ensure_distinct_paths(self, target)
try:
copy_to_target = target._copy_from
except AttributeError:
raise TypeError(f"Target path is not writable: {target!r}") from None
copy_to_target(self, **kwargs)
target._copy_from(self, **kwargs)
return target.joinpath() # Empty join to ensure fresh metadata.

def copy_into(self, target_dir, **kwargs):
Expand Down
6 changes: 1 addition & 5 deletions Lib/pathlib/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,7 @@ def copy(self, target, **kwargs):
Recursively copy this file or directory tree to the given destination.
"""
ensure_distinct_paths(self, target)
try:
copy_to_target = target._copy_from
except AttributeError:
raise TypeError(f"Target path is not writable: {target!r}") from None
copy_to_target(self, **kwargs)
target._copy_from(self, **kwargs)
return target.joinpath() # Empty join to ensure fresh metadata.

def copy_into(self, target_dir, **kwargs):
Expand Down
Loading
0