Skip to content

Commit 0468a85

Browse files
Clarify that shutil's copy functions can accept path-like values (GH-15141)
(cherry picked from commit 9488a52) Co-authored-by: Boris Verhovsky <[email protected]>
1 parent 5731172 commit 0468a85

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Doc/library/shutil.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Directory and files operations
5252

5353
Copy the contents (no metadata) of the file named *src* to a file named
5454
*dst* and return *dst* in the most efficient way possible.
55-
*src* and *dst* are path names given as strings.
55+
*src* and *dst* are path-like objects or path names given as strings.
5656

5757
*dst* must be the complete target file name; look at :func:`~shutil.copy`
5858
for a copy that accepts a target directory path. If *src* and *dst*
@@ -92,7 +92,8 @@ Directory and files operations
9292
.. function:: copymode(src, dst, *, follow_symlinks=True)
9393

9494
Copy the permission bits from *src* to *dst*. The file contents, owner, and
95-
group are unaffected. *src* and *dst* are path names given as strings.
95+
group are unaffected. *src* and *dst* are path-like objects or path names
96+
given as strings.
9697
If *follow_symlinks* is false, and both *src* and *dst* are symbolic links,
9798
:func:`copymode` will attempt to modify the mode of *dst* itself (rather
9899
than the file it points to). This functionality is not available on every
@@ -108,7 +109,8 @@ Directory and files operations
108109
Copy the permission bits, last access time, last modification time, and
109110
flags from *src* to *dst*. On Linux, :func:`copystat` also copies the
110111
"extended attributes" where possible. The file contents, owner, and
111-
group are unaffected. *src* and *dst* are path names given as strings.
112+
group are unaffected. *src* and *dst* are path-like objects or path
113+
names given as strings.
112114

113115
If *follow_symlinks* is false, and *src* and *dst* both
114116
refer to symbolic links, :func:`copystat` will operate on

Lib/shutil.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ def copystat(src, dst, *, follow_symlinks=True):
330330
Copy the permission bits, last access time, last modification time, and
331331
flags from `src` to `dst`. On Linux, copystat() also copies the "extended
332332
attributes" where possible. The file contents, owner, and group are
333-
unaffected. `src` and `dst` are path names given as strings.
333+
unaffected. `src` and `dst` are path-like objects or path names given as
334+
strings.
334335
335336
If the optional flag `follow_symlinks` is not set, symlinks aren't
336337
followed if and only if both `src` and `dst` are symlinks.

0 commit comments

Comments
 (0)