Skip to content

Commit 78e2438

Browse files
committed
gh-113803: Fix inaccurate documentation for shutil.move when dst is an existing directory #113803
1 parent 809eed4 commit 78e2438

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

Doc/library/shutil.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,15 @@ Directory and files operations
360360

361361
.. function:: move(src, dst, copy_function=copy2)
362362

363-
Recursively move a file or directory (*src*) to another location (*dst*)
364-
and return the destination.
363+
Recursively move a file or directory (*src*) to another location and return
364+
the destination.
365365

366-
If the destination is an existing directory, then *src* is moved inside that
367-
directory. If the destination already exists but is not a directory, it may
368-
be overwritten depending on :func:`os.rename` semantics.
366+
If *dst* is an existing directory or a symlink to a directory, then *src*
367+
is moved inside that directory. The destination path in that directory must
368+
not already exist.
369+
370+
If the destination already exists but is not a directory, it may be
371+
overwritten depending on :func:`os.rename` semantics.
369372

370373
If the destination is on the current filesystem, then :func:`os.rename` is
371374
used. Otherwise, *src* is copied to *dst* using *copy_function* and then

Lib/shutil.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -861,9 +861,9 @@ def move(src, dst, copy_function=copy2):
861861
similar to the Unix "mv" command. Return the file or directory's
862862
destination.
863863
864-
If the destination is a directory or a symlink to a directory, the source
865-
is moved inside the directory. The destination path must not already
866-
exist.
864+
If dst is an existing directory or a symlink to a directory, then src is
865+
moved inside that directory. The destination path in that directory must
866+
not already exist.
867867
868868
If the destination already exists but is not a directory, it may be
869869
overwritten depending on os.rename() semantics.

0 commit comments

Comments
 (0)