Skip to content

Commit 08bc0f8

Browse files
0000matteo0000matteo.porta
authored andcommitted
fix shutil.copytree() failing to override existing symbolic links
1 parent a1a3193 commit 08bc0f8

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)