[Python-checkins] Clarify that shutil's copy functions can accept path-like values (GH-15141)

Miss Islington (bot) webhook-mailer at python.org
Mon Sep 9 13:18:55 EDT 2019


https://github.com/python/cpython/commit/0468a85cc4a3bd870f7e119ef8e6a2af0177ac56
commit: 0468a85cc4a3bd870f7e119ef8e6a2af0177ac56
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-09-09T10:18:51-07:00
summary:

Clarify that shutil's copy functions can accept path-like values (GH-15141)

(cherry picked from commit 9488a5289de2ceecdfd2098cd70d215f96c4e745)

Co-authored-by: Boris Verhovsky <boris.verk at gmail.com>

files:
M Doc/library/shutil.rst
M Lib/shutil.py

diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst
index a51e068ebd59..88c5f62dd4c9 100644
--- a/Doc/library/shutil.rst
+++ b/Doc/library/shutil.rst
@@ -52,7 +52,7 @@ Directory and files operations
 
    Copy the contents (no metadata) of the file named *src* to a file named
    *dst* and return *dst* in the most efficient way possible.
-   *src* and *dst* are path names given as strings.
+   *src* and *dst* are path-like objects or path names given as strings.
 
    *dst* must be the complete target file name; look at :func:`~shutil.copy`
    for a copy that accepts a target directory path.  If *src* and *dst*
@@ -92,7 +92,8 @@ Directory and files operations
 .. function:: copymode(src, dst, *, follow_symlinks=True)
 
    Copy the permission bits from *src* to *dst*.  The file contents, owner, and
-   group are unaffected.  *src* and *dst* are path names given as strings.
+   group are unaffected.  *src* and *dst* are path-like objects or path names
+   given as strings.
    If *follow_symlinks* is false, and both *src* and *dst* are symbolic links,
    :func:`copymode` will attempt to modify the mode of *dst* itself (rather
    than the file it points to).  This functionality is not available on every
@@ -108,7 +109,8 @@ Directory and files operations
    Copy the permission bits, last access time, last modification time, and
    flags from *src* to *dst*.  On Linux, :func:`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.
+   group are unaffected.  *src* and *dst* are path-like objects or path
+   names given as strings.
 
    If *follow_symlinks* is false, and *src* and *dst* both
    refer to symbolic links, :func:`copystat` will operate on
diff --git a/Lib/shutil.py b/Lib/shutil.py
index 561ad71508cc..5c1255a6713d 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -330,7 +330,8 @@ def copystat(src, dst, *, follow_symlinks=True):
     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.
+    unaffected. `src` and `dst` are path-like objects or 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.



More information about the Python-checkins mailing list