From 3db0e1802072dcb2553aa09db23335ae93b6433a Mon Sep 17 00:00:00 2001 From: barneygale Date: Fri, 1 Nov 2024 23:45:30 +0000 Subject: [PATCH] Fix missed Windows changes --- Lib/pathlib/_local.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Lib/pathlib/_local.py b/Lib/pathlib/_local.py index 1ad11fa872728d..a5e82ec5f468b6 100644 --- a/Lib/pathlib/_local.py +++ b/Lib/pathlib/_local.py @@ -78,10 +78,16 @@ def copy_file(self, source, target, metadata_keys, dir_entry=None): if os.name == 'nt': def copy_symlink(self, source, target, metadata_keys, dir_entry=None): """Copy the given symlink to the given target.""" - metadata = source._read_metadata( - metadata_keys, follow_symlinks=False, dir_entry=dir_entry) - target.symlink_to(source.readlink(), (dir_entry or source).is_dir()) - target._write_metadata(metadata, follow_symlinks=False) + if metadata_keys: + metadata = source._read_metadata( + metadata_keys, follow_symlinks=False, dir_entry=dir_entry) + else: + metadata = None + symlink_target = source.readlink() + symlink_is_directory = (dir_entry or source).is_dir() + target.symlink_to(symlink_target, symlink_is_directory) + if metadata: + target._write_metadata(metadata, follow_symlinks=False) class PurePath(PurePathBase):