[New-bugs-announce] [issue47049] Incorrect shutil.copytree() behaviour with symlinks

Zoltan Vajda report at bugs.python.org
Thu Mar 17 14:50:19 EDT 2022

New submission from Zoltan Vajda <vzvzvz2 at gmail.com>:

shutil.copytree incorrectly does not copy symlink contents if called
with symlink=False and ignore_dangling_symlinks=True.

The wrong behaviour can be reproduced like this:

$ tree
└── a
    ├── a.txt
    └── b
        └── a.txt -> ../a.txt

$ python3 -c "import shutil;shutil.copytree('a/b', 'c', symlinks=False, ignore_dangling_symlinks=True)"

As a result directoy c will be created but it will remain empty.
Expected result is a file c/a.txt with the contents of a/b/a.txt.

components: Library (Lib)
messages: 415437
nosy: vajdaz
priority: normal
severity: normal
status: open
title: Incorrect shutil.copytree() behaviour with symlinks
versions: Python 3.11

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list