Skip to content

Commit 550a52a

Browse files
author
matteo.porta
committed
fix shutil.copytree() failing to override existing symbolic links
1 parent a1a3193 commit 550a52a

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
@@ -507,6 +507,8 @@ def _copytree(entries, src, dst, symlinks, ignore, copy_function,
507507
# We can't just leave it to `copy_function` because legacy
508508
# code with a custom `copy_function` may rely on copytree
509509
# doing the right thing.
510+
if dirs_exist_ok and os.path.lexists(dstname):
511+
os.unlink(dstname)
510512
os.symlink(linkto, dstname)
511513
copystat(srcobj, dstname, follow_symlinks=not symlinks)
512514
else:

0 commit comments

Comments
 (0)