Skip to content

Commit 48e214e

Browse files
fix shutil.copytree() failing to override existing symbolic links
1 parent ab48ba8 commit 48e214e

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎Lib/shutil.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,8 @@ def _copytree(entries, src, dst, symlinks, ignore, copy_function,
590590
# We can't just leave it to `copy_function` because legacy
591591
# code with a custom `copy_function` may rely on copytree
592592
# doing the right thing.
593+
if dirs_exist_ok and os.path.lexists(dstname):
594+
os.unlink(dstname)
593595
os.symlink(linkto, dstname)
594596
copystat(srcobj, dstname, follow_symlinks=not symlinks)
595597
else:

0 commit comments

Comments
 (0)