This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: distutils.dir_util.copy_tree FileExistsError when updating symlinks
Type: behavior Stage: resolved
Components: Distutils Versions: Python 3.10
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Tom Hale, dstufft, eric.araujo, steve.dower
Priority: normal Keywords: patch

Created on 2020-06-27 03:26 by Tom Hale, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 14464 open Tom Hale, 2020-07-17 05:28
Messages (2)
msg372449 - (view) Author: Tom Hale (Tom Hale) * Date: 2020-06-27 03:26
Here is a minimal test case:


cd /tmp || exit 1


mkdir -p "$src"
touch "$src"/file
ln -s file "$src/symlink"

python -c "from distutils.dir_util import copy_tree;
copy_tree('$src', '$dst', preserve_symlinks=1, update=1);
copy_tree('$src', '$dst', preserve_symlinks=1, update=1);"

rm -r "$dir"


Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "/usr/lib/python3.8/distutils/", line 152, in copy_tree
    os.symlink(link_dest, dst_name)
FileExistsError: [Errno 17] File exists: 'file' -> 'test-copy_tree/dst/symlink'



This issue will likely be resolved via:

bpo-36656 Add race-free and os.symlink wrapper / helper
(WIP under discussion at python-mentor)

Prior art:
msg386251 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-02-03 18:06
Distutils is now deprecated (see PEP 632) and all tagged issues are being closed. From now until removal, only release blocking issues will be considered for distutils.

If this issue does not relate to distutils, please remove the component and reopen it. If you believe it still requires a fix, most likely the issue should be re-reported at
Date User Action Args
2022-04-11 14:59:32adminsetgithub: 85306
2021-02-03 18:06:06steve.dowersetstatus: open -> closed

dependencies: - Add race-free and os.symlink wrapper / helper

nosy: + steve.dower
messages: + msg386251
resolution: out of date
stage: patch review -> resolved
2020-09-19 19:02:34iritkatrielsetnosy: + eric.araujo, dstufft
type: behavior
components: + Distutils
2020-07-29 12:50:05terry.reedysetdependencies: + Add race-free and os.symlink wrapper / helper
versions: + Python 3.10
2020-07-17 05:28:01Tom Halesetkeywords: + patch
stage: patch review
pull_requests: + pull_request20651
2020-06-27 03:26:02Tom Halecreate