[New-bugs-announce] [issue24609] shutil.copytree fails with symlinks to directories when symlink=False

Thomas Kluyver report at bugs.python.org
Fri Jul 10 23:22:21 CEST 2015


New submission from Thomas Kluyver:

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.

----------
components: Library (Lib)
files: shutil_copytree_symlink_dir.patch
keywords: patch
messages: 246585
nosy: takluyver
priority: normal
severity: normal
status: open
title: shutil.copytree fails with symlinks to directories when symlink=False
versions: Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file39892/shutil_copytree_symlink_dir.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24609>
_______________________________________


More information about the New-bugs-announce mailing list