]> granicus.if.org Git - python/commitdiff
bpo-34260, shutil: fix copy2 and copystat documentation (GH-8523)
authorZsolt Cserna <cserna.zsolt@gmail.com>
Tue, 23 Oct 2018 10:09:50 +0000 (12:09 +0200)
committerVictor Stinner <vstinner@redhat.com>
Tue, 23 Oct 2018 10:09:50 +0000 (12:09 +0200)
Fix the documentation of copy2, as it does not copy file ownership (user and
group), only mode, mtime, atime and flags.

The original text was confusing to developers as it suggested that this
command is the same as 'cp -p', but according to cp(1), '-p' copies file
ownership as well.

Clarify which metadata is copied by shutil.copystat in its docstring.

Doc/library/shutil.rst
Lib/shutil.py

index 6b4ce14b5da12304c92fe75e3ee7375ac50df708..7a596eeff6828fd717203f6a2df28c223d580d35 100644 (file)
@@ -177,7 +177,7 @@ Directory and files operations
 .. function:: copy2(src, dst, *, follow_symlinks=True)
 
    Identical to :func:`~shutil.copy` except that :func:`copy2`
-   also attempts to preserve all file metadata.
+   also attempts to preserve file metadata.
 
    When *follow_symlinks* is false, and *src* is a symbolic
    link, :func:`copy2` attempts to copy all metadata from the
index a4aa0dfdd10b097aad55757ba818bd5376a6fa42..40dd070ed11f793a8d356a6373f1e9305b7b6944 100644 (file)
@@ -312,11 +312,15 @@ else:
         pass
 
 def copystat(src, dst, *, follow_symlinks=True):
-    """Copy all stat info (mode bits, atime, mtime, flags) from src to dst.
+    """Copy file metadata
 
-    If the optional flag `follow_symlinks` is not set, symlinks aren't followed if and
-    only if both `src` and `dst` are symlinks.
+    Copy the permission bits, last access time, last modification time, and
+    flags from `src` to `dst`. On Linux, copystat() also copies the "extended
+    attributes" where possible. The file contents, owner, and group are
+    unaffected. `src` and `dst` are path names given as strings.
 
+    If the optional flag `follow_symlinks` is not set, symlinks aren't
+    followed if and only if both `src` and `dst` are symlinks.
     """
     def _nop(*args, ns=None, follow_symlinks=None):
         pass
@@ -384,8 +388,10 @@ def copy(src, dst, *, follow_symlinks=True):
     return dst
 
 def copy2(src, dst, *, follow_symlinks=True):
-    """Copy data and all stat info ("cp -p src dst"). Return the file's
-    destination.
+    """Copy data and metadata. Return the file's destination.
+
+    Metadata is copied with copystat(). Please see the copystat function
+    for more information.
 
     The destination may be a directory.