aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Doc/library/shutil.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/shutil.rst')
-rw-r--r--Doc/library/shutil.rst26
1 files changed, 23 insertions, 3 deletions
diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst
index 2cbf95bcf53..dde38498206 100644
--- a/Doc/library/shutil.rst
+++ b/Doc/library/shutil.rst
@@ -47,6 +47,13 @@ Directory and files operations
0, only the contents from the current file position to the end of the file will
be copied.
+ :func:`copyfileobj` will *not* guarantee that the destination stream has
+ been flushed on completion of the copy. If you want to read from the
+ destination at the completion of the copy operation (for example, reading
+ the contents of a temporary file that has been copied from a HTTP stream),
+ you must ensure that you have called :func:`~io.IOBase.flush` or
+ :func:`~io.IOBase.close` on the file-like object before attempting to read
+ the destination file.
.. function:: copyfile(src, dst, *, follow_symlinks=True)
@@ -327,6 +334,10 @@ Directory and files operations
The deprecated *onerror* is similar to *onexc*, except that the third
parameter it receives is the tuple returned from :func:`sys.exc_info`.
+ .. seealso::
+ :ref:`shutil-rmtree-example` for an example of handling the removal
+ of a directory tree that contains read-only files.
+
.. audit-event:: shutil.rmtree path,dir_fd shutil.rmtree
.. versionchanged:: 3.3
@@ -454,6 +465,10 @@ Directory and files operations
:envvar:`PATH` environment variable is read from :data:`os.environ`,
falling back to :data:`os.defpath` if it is not set.
+ If *cmd* contains a directory component, :func:`!which` only checks the
+ specified path directly and does not search the directories listed in
+ *path* or in the system's :envvar:`PATH` environment variable.
+
On Windows, the current directory is prepended to the *path* if *mode* does
not include ``os.X_OK``. When the *mode* does include ``os.X_OK``, the
Windows API ``NeedCurrentDirectoryForExePathW`` will be consulted to
@@ -603,7 +618,8 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
*format* is the archive format: one of
"zip" (if the :mod:`zlib` module is available), "tar", "gztar" (if the
:mod:`zlib` module is available), "bztar" (if the :mod:`bz2` module is
- available), or "xztar" (if the :mod:`lzma` module is available).
+ available), "xztar" (if the :mod:`lzma` module is available), or "zstdtar"
+ (if the :mod:`compression.zstd` module is available).
*root_dir* is a directory that will be the root directory of the
archive, all paths in the archive will be relative to it; for example,
@@ -658,6 +674,8 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
- *gztar*: gzip'ed tar-file (if the :mod:`zlib` module is available).
- *bztar*: bzip2'ed tar-file (if the :mod:`bz2` module is available).
- *xztar*: xz'ed tar-file (if the :mod:`lzma` module is available).
+ - *zstdtar*: Zstandard compressed tar-file (if the :mod:`compression.zstd`
+ module is available).
You can register new formats or provide your own archiver for any existing
formats, by using :func:`register_archive_format`.
@@ -701,8 +719,8 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
*extract_dir* is the name of the target directory where the archive is
unpacked. If not provided, the current working directory is used.
- *format* is the archive format: one of "zip", "tar", "gztar", "bztar", or
- "xztar". Or any other format registered with
+ *format* is the archive format: one of "zip", "tar", "gztar", "bztar",
+ "xztar", or "zstdtar". Or any other format registered with
:func:`register_unpack_format`. If not provided, :func:`unpack_archive`
will use the archive file name extension and see if an unpacker was
registered for that extension. In case none is found,
@@ -774,6 +792,8 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
- *gztar*: gzip'ed tar-file (if the :mod:`zlib` module is available).
- *bztar*: bzip2'ed tar-file (if the :mod:`bz2` module is available).
- *xztar*: xz'ed tar-file (if the :mod:`lzma` module is available).
+ - *zstdtar*: Zstandard compressed tar-file (if the :mod:`compression.zstd`
+ module is available).
You can register new formats or provide your own unpacker for any existing
formats, by using :func:`register_unpack_format`.