8000 GH-73991: Support preserving metadata in `pathlib.Path.copy()` by barneygale · Pull Request #120806 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-73991: Support preserving metadata in pathlib.Path.copy() #120806

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 15 commits into from
Jul 6, 2024
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
Remove some code that's now unused.
  • Loading branch information
barneygale committed Jun 24, 2024
commit 8129c4670f33b94933cb2e44e7f01418aef5dd35
9 changes: 3 additions & 6 deletions Lib/pathlib/_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,14 @@ def copyfileobj(source_f, target_f):


def get_file_metadata(path, follow_symlinks):
if isinstance(path, os.DirEntry):
st = path.stat(follow_symlinks=follow_symlinks)
else:
st = os.stat(path, follow_symlinks=follow_symlinks)
st = os.stat(path, follow_symlinks=follow_symlinks)
result = {
'mode': stat.S_IMODE(st.st_mode),
'atime_ns': st.st_atime_ns,
'mtime_ns': st.st_mtime_ns,
}
if hasattr(st, 'st_flags'):
result['flags'] = st.st_flags
if hasattr(os, 'listxattr'):
try:
result['xattrs'] = [
Expand All @@ -177,8 +176,6 @@ def get_file_metadata(path, follow_symlinks):
except OSError as err:
if err.errno not in (EPERM, ENOTSUP, ENODATA, EINVAL, EACCES):
raise
if hasattr(st, 'st_flags'):
result['flags'] = st.st_flags
return result


Expand Down
Loading
0