summaryrefslogtreecommitdiffstats
path: root/Lib/shutil.py
diff options
context:
space:
mode:
authorJack DeVries <jdevries3133@gmail.com>2022-04-12 00:57:52 (GMT)
committerGitHub <noreply@github.com>2022-04-12 00:57:52 (GMT)
commitf33e2c87a83917b5139d97fd8ef7cba7223ebef5 (patch)
treef94e49fc91aec647ed24d6d002efa00e3916b6c5 /Lib/shutil.py
parent9ebcece82fe11b87cc3d6e6b4c439aab9e3ab1e6 (diff)
downloadcpython-f33e2c87a83917b5139d97fd8ef7cba7223ebef5.zip
cpython-f33e2c87a83917b5139d97fd8ef7cba7223ebef5.tar.gz
cpython-f33e2c87a83917b5139d97fd8ef7cba7223ebef5.tar.bz2
gh-88513: clarify shutil.copytree's dirs_exist_ok arg (GH-91434)
* add a paragraph to document this kwarg in detail * update docstring in the source accordingly
Diffstat (limited to 'Lib/shutil.py')
-rw-r--r--Lib/shutil.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/shutil.py b/Lib/shutil.py
index 22bd86d..de82453 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -518,9 +518,6 @@ def copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2,
ignore_dangling_symlinks=False, dirs_exist_ok=False):
"""Recursively copy a directory tree and return the destination directory.
- dirs_exist_ok dictates whether to raise an exception in case dst or any
- missing parent directory already exists.
-
If exception(s) occur, an Error is raised with a list of reasons.
If the optional symlinks flag is true, symbolic links in the
@@ -551,6 +548,11 @@ def copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2,
destination path as arguments. By default, copy2() is used, but any
function that supports the same signature (like copy()) can be used.
+ If dirs_exist_ok is false (the default) and `dst` already exists, a
+ `FileExistsError` is raised. If `dirs_exist_ok` is true, the copying
+ operation will continue if it encounters existing directories, and files
+ within the `dst` tree will be overwritten by corresponding files from the
+ `src` tree.
"""
sys.audit("shutil.copytree", src, dst)
with os.scandir(src) as itr: