Skip to content
Merged
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
Merge branch 'main' into copy-metadata
  • Loading branch information
barneygale committed Jul 3, 2024
commit d31246907f67e9d9cc39dda34b3c8c380b5e6fd9
23 changes: 13 additions & 10 deletions Lib/pathlib/_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
except ImportError:
grp = None

from ._abc import UnsupportedOperation, PurePathBase, PathBase
from ._os import copyfile, file_metadata_keys, get_file_metadata, set_file_metadata
from ._os import (UnsupportedOperation, copyfile, file_metadata_keys,
get_file_metadata, set_file_metadata)
from ._abc import PurePathBase, PathBase


__all__ = [
Expand Down Expand Up @@ -795,14 +796,16 @@ def copy(self, target, *, follow_symlinks=True, preserve_metadata=False):
try:
target = os.fspath(target)
except TypeError:
if isinstance(target, PathBase):
# Target is an instance of PathBase but not os.PathLike.
# Use generic implementation from PathBase.
return PathBase.copy(self, target,
follow_symlinks=follow_symlinks,
preserve_metadata=preserve_metadata)
raise
copyfile(os.fspath(self), target, follow_symlinks)
if not isinstance(target, PathBase):
raise
else:
try:
copyfile(os.fspath(self), target, follow_symlinks)
return
except UnsupportedOperation:
pass # Fall through to generic code.
PathBase.copy(self, target, follow_symlinks=follow_symlinks,
preserve_metadata=preserve_metadata)

def chmod(self, mode, *, follow_symlinks=True):
"""
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.