classification
Title: shutil.copytree fails with symlinks to directories when symlink=False
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.6, Python 3.4, Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: shutil.copytree() handles symbolic directory incorrectly
View: 21697
Assigned To: Nosy List: berker.peksag, takluyver
Priority: normal Keywords: patch

Created on 2015-07-10 21:22 by takluyver, last changed 2015-07-10 21:41 by berker.peksag. This issue is now closed.

Files
File name Uploaded Description Edit
shutil_copytree_symlink_dir.patch takluyver, 2015-07-10 21:22 review
Messages (2)
msg246585 - (view) Author: Thomas Kluyver (takluyver) * Date: 2015-07-10 21:22
shutil.copytree behaves differently with symlinks depending on the 'symlinks' parameter. If this is True, symlinks are replicated in the destination. If False, the contents of the targets are copied to the destination.

With symlinks=False, it currently assumes that all symlinks are pointing to regular files. With a symlink to a directory, it tries to copy it using the file copy function, which fails with:

[Errno 21] Is a directory: '/tmp/tmpouavxt1u/link_to_dir'"

The attached patch adds an isdir() check to use copytree instead in that case. A test is also added.
msg246586 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-07-10 21:41
Thanks for the report and the patch. This is a duplicate of issue 21697. Could you please attach the patch in that issue?
History
Date User Action Args
2015-07-10 21:41:41berker.peksagsetstatus: open -> closed

superseder: shutil.copytree() handles symbolic directory incorrectly

nosy: + berker.peksag
messages: + msg246586
resolution: duplicate
stage: resolved
2015-07-10 21:22:21takluyvercreate