Skip to content

Commit 2c24bc1

Browse files
authored
gh-160322: document shutil.rmtree("link/") symlink following behavior (GH-160372)
1 parent 1f1ae14 commit 2c24bc1

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎Doc/library/shutil.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,12 @@ Directory and files operations
325325
handled by calling a handler specified by *onexc* or *onerror* or, if both
326326
are omitted, exceptions are propagated to the caller.
327327

328+
If *path* is a symbolic link to a directory followed by a trailing path
329+
separator, such as ``'link/'``, the operating system resolves the link, so
330+
:func:`!rmtree` deletes the contents of the directory it points to and then
331+
fails to remove *path* itself. :class:`pathlib.Path` strips trailing
332+
separators, so ``rmtree(Path('link/'))`` refuses the link as usual.
333+
328334
This function can support :ref:`paths relative to directory descriptors
329335
<dir_fd>`.
330336

0 commit comments

Comments
 (0)