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
Apply suggestions from code review
Co-authored-by: Eryk Sun <eryksun@gmail.com>
  • Loading branch information
barneygale and eryksun authored Jun 6, 2024
commit 7c9c893f93036e1b332934b83e11b5e036091a32
5 changes: 3 additions & 2 deletions Lib/pathlib/_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def copyfd(source_fd, target_fd):
def is_dirlink(path):
try:
st = os.lstat(path)
except OSError:
except (OSError, ValueError):
return False
return (st.st_file_attributes & stat.FILE_ATTRIBUTE_DIRECTORY and
st.st_reparse_tag == stat.IO_REPARSE_TAG_SYMLINK)
Expand All @@ -111,10 +111,11 @@ def copyfile(source, target, follow_symlinks):
flags = _winapi.COPY_FILE_COPY_SYMLINK
try:
_winapi.CopyFile2(source, target, flags)
Comment thread
barneygale marked this conversation as resolved.
Outdated
return
except OSError as err:
# Check for ERROR_ACCESS_DENIED
if err.winerror != 5 or not is_dirlink(source):
raise err
raise
flags |= _winapi.COPY_FILE_DIRECTORY
_winapi.CopyFile2(source, target, flags)
else:
Expand Down