Skip to content

bpo-44347: [doc] clarify meaning of shutil.copytree's dirs_exist_ok kwarg #26643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 70 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
74727b9
bpo-44347: [doc] clarify meaning of shutil.copytree's dirs_exist_ok …
jdevries3133 Jun 9, 2021
0fa96d1
bpo-44347: [doc] clarify shutil.copytree dirs_exist_ok kwarg
jdevries3133 Jun 10, 2021
318a99c
Merge branch 'main' of github.com:python/cpython into bpo-44347
jdevries3133 Jun 10, 2021
9b262b8
bpo-44347: [doc|fix]: add NEWS.d entry, remove use of default context
jdevries3133 Jun 10, 2021
952dbf1
Merge branch 'main' of github.com:python/cpython into bpo-44347
jdevries3133 Jun 10, 2021
e365e52
bpo-44347: [doc] better document argument shutil.copytree(dirs_exist_…
jdevries3133 Jun 11, 2021
eb3ee6f
Merge branch 'main' of github.com:python/cpython into bpo-44347
jdevries3133 Jun 11, 2021
d340c87
bpo-44347: [doc|fix]: add missed updated docstring from previous commit
jdevries3133 Jun 11, 2021
dd2f5c3
bpo-44381: Windows build now allows enabling control flow guard (GH-2…
zooba Jun 11, 2021
d8837d8
bpo-40128: Fix IDLE autocomplete on macOS (GH-26672)
thsubaku9 Jun 11, 2021
869f2fa
bpo-44339: Fix math.pow corner case to comply with IEEE 754 (GH-26606)
mdickinson Jun 12, 2021
29584b7
bpo-43475: Fix the Python implementation of hash of Decimal NaN (GH-2…
serhiy-storchaka Jun 12, 2021
b63a793
Add more const modifiers. (GH-26691)
serhiy-storchaka Jun 12, 2021
feca673
bpo-44376 - reduce pow() overhead for small exponents (GH-26662)
tim-one Jun 12, 2021
b1e8a39
bpo-44396: Update multi-line-start location when reallocating tokeniz…
pablogsal Jun 12, 2021
732ecab
bpo-44389: Remove duplicate SSL_OP_NO_TLSv1_2 flag (GH-26680)
Jun 12, 2021
2a93215
bpo-43425: Update test_c_parser not to use TempdirManager (GH-26693)
corona10 Jun 12, 2021
50aee65
Fix typos in multiple files (GH-26689)
enjoy-binbin Jun 13, 2021
6966890
Fix a potential reference-counting bug in long_pow (GH-26690)
mdickinson Jun 13, 2021
d1a2233
bpo-44389: Fix deprecation of OP_NO_TLSv1_3 (GH-26700)
tiran Jun 13, 2021
67d241b
bpo-44310: Note that lru_cache keep references to both arguments and…
rhettinger Jun 14, 2021
0208b06
bpo-44338: Port LOAD_GLOBAL to PEP 659 adaptive interpreter (GH-26638)
markshannon Jun 14, 2021
ad667a2
Remove accidentally duplicated STAT_INC (GH-26718)
markshannon Jun 14, 2021
6109bfa
bpo-38291: Remove mention of typing.io and typing.re again (GH-26113)
srittau Jun 14, 2021
101dc7e
Fix typo in lnotab_notes.txt (GH-26711)
P403n1x87 Jun 14, 2021
ed3d0b5
bpo-44409: Fix error location in tokenizer errors that happen during …
pablogsal Jun 14, 2021
44d2ad8
Fix a typo in _make_class_unpicklable() docstring (GH-26729)
akulakov Jun 15, 2021
77b67cb
Add extra stats for attribute misses (GH-26732)
markshannon Jun 15, 2021
1628fb8
bpo-42064: Move sqlite3 types to global state (GH-26537)
Jun 15, 2021
c60a9c6
bpo-42972: _thread.RLock implements the GH protocol (GH-26734)
vstinner Jun 15, 2021
1d63579
bpo-44422: Fix threading.enumerate() reentrant call (GH-26727)
vstinner Jun 15, 2021
3e45844
[Enum] improve test, add andrei kulakov to ACKS (GH-26726)
ethanfurman Jun 15, 2021
3e2e824
bpo-43475: Add what's new entry for NaN hash changes (GH-26725)
mdickinson Jun 15, 2021
fc3ca19
bpo-43693: Eliminate unused "fast locals". (gh-26587)
ericsnowcurrently Jun 15, 2021
949a2b7
bpo-44342: [Enum] sync current docs to 3.10 (GH-26750)
ethanfurman Jun 16, 2021
b7f3aca
bpo-43795: Don't list private names in the limited API (GH-26740)
encukou Jun 16, 2021
8fc6dd3
bpo-44422: threading.Thread reuses the _delete() method (GH-26741)
vstinner Jun 16, 2021
66eab7a
bpo-38211: Clean up type_init() (GH-16257)
sir-sigurd Jun 16, 2021
e78f506
bpo-44392: Add Py_GenericAlias to C API docs (GH-26724)
Fidget-Spinner Jun 16, 2021
66c976d
bpo-44426: Use of 'complex' as a C variable name confuses Sphinx; cha…
mdickinson Jun 16, 2021
439482a
bpo-44389: Fix typo in ssl deprecation warning message (GH-26754)
j178 Jun 17, 2021
76bed3a
bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-…
Jun 17, 2021
f446866
Do not clear globals or builtins when calling clear() on a frame obje…
markshannon Jun 17, 2021
3010391
bpo-43024: improve signature (in help, etc) for functions taking sent…
iritkatriel Jun 17, 2021
6e231c0
bpo-44310: Add a FAQ entry for caching method calls (GH-26731)
rhettinger Jun 17, 2021
9ad9fd7
bpo-44032: Move pointer to code object from frame-object to frame spe…
markshannon Jun 18, 2021
95aa9d6
Reorganize the pattern matching suite (GH-26661)
brandtbucher Jun 18, 2021
d808829
bpo-44451: Reset DeprecationWarning filters in test_importlib.test_en…
hroncok Jun 18, 2021
f3dd96a
bpo-43945: [Enum] reduce scope of new format() behavior (GH-26752)
ethanfurman Jun 18, 2021
d4b87bc
Add a note about NameError/AttributeError suggestions with custom err…
pablogsal Jun 18, 2021
32fd669
Remove dubious suggestion (GH-26789)
rhettinger Jun 19, 2021
df719d4
bpo-38820: Test with OpenSSL 3.0.0-beta1 (GH-26769)
tiran Jun 19, 2021
0cf3409
bpo-43298: Improved error message when building without the Windows S…
zooba Jun 19, 2021
07f631d
bpo-44426: Fix use of the C keyword 'default' as a variable name (GH-…
mdickinson Jun 19, 2021
f879593
Merge remote-tracking branch 'upstream/main' into pr_26643
terryjreedy Jun 19, 2021
d035783
commit suggested change from @terryjreedy
jdevries3133 Jun 20, 2021
a1f767c
commit suggested change from @terryjreedy
jdevries3133 Jun 20, 2021
7151b46
commit suggested change from @terryjreedy
jdevries3133 Jun 20, 2021
a0a46be
commit suggested change from @terryjreedy
jdevries3133 Jun 20, 2021
e02e998
bpo-38291: DeprecationWarning when importing typing.{io,re} (#26719)
srittau Jun 19, 2021
82ae9d6
bpo-44347: fix spelling
jdevries3133 Jun 20, 2021
568c773
Merge remote-tracking branch 'upstream/main' into pr_26643
terryjreedy Jun 20, 2021
b2d7cc0
bpo-44347: add note to further clarify edge case
jdevries3133 Jun 21, 2021
a07b324
bpo-44347: (small fix) remove redundant line from example
jdevries3133 Jun 21, 2021
48f30ee
bpo-44347: highlight relationship to os.makedirs
jdevries3133 Jun 21, 2021
5b8366a
small rewording fix
jdevries3133 Jul 1, 2021
60a0eb6
Merge branch 'main' of github.com:python/cpython into bpo-44347
jdevries3133 Apr 8, 2022
8303dc5
revise old changes
jdevries3133 Apr 8, 2022
c169b1d
apply @JelleZijlstra's feedback
jdevries3133 Apr 9, 2022
ac3f837
update docstring
jdevries3133 Apr 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions Doc/library/shutil.rst
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,8 @@ Directory and files operations
dirs_exist_ok=False)

Recursively copy an entire directory tree rooted at *src* to a directory
named *dst* and return the destination directory. *dirs_exist_ok* dictates
whether to raise an exception in case *dst* or any missing parent directory
already exists.
named *dst* and return the destination directory. All intermediate
directories needed to contain *dst* will also be created by default.

Permissions and times of directories are copied with :func:`copystat`,
individual files are copied using :func:`~shutil.copy2`.
Expand Down Expand Up @@ -263,8 +262,14 @@ Directory and files operations

If *copy_function* is given, it must be a callable that will be used to copy
each file. It will be called with the source path and the destination path
  as arguments. By default, :func:`~shutil.copy2` is used, but any function
  that supports the same signature (like :func:`~shutil.copy`) can be used.
as arguments. By default, :func:`~shutil.copy2` is used, but any function
that supports the same signature (like :func:`~shutil.copy`) can be used.

If *dirs_exist_ok* is false (the default) and *dst* already exists, a
:exc:`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.

.. audit-event:: shutil.copytree src,dst shutil.copytree

Expand All @@ -275,7 +280,7 @@ Directory and files operations
.. versionchanged:: 3.2
Added the *copy_function* argument to be able to provide a custom copy
function.
Added the *ignore_dangling_symlinks* argument to silent dangling symlinks
Added the *ignore_dangling_symlinks* argument to silence dangling symlinks
errors when *symlinks* is false.

.. versionchanged:: 3.8
Expand Down
8 changes: 5 additions & 3 deletions Lib/shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Clarify the meaning of *dirs_exist_ok*, a kwarg passed to the
:func:`shutil.copytree` function.