Skip to content

Commit 5d8f1c7

Browse files
committed
gh-160322: document shutil.rmtree("link/") symlink following behavior
1 parent d98f2cb commit 5d8f1c7

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎Doc/library/shutil.rst‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,13 @@ Directory and files operations
316316
handled by calling a handler specified by *onexc* or *onerror* or, if both
317317
are omitted, exceptions are propagated to the caller.
318318

319+
As with other path-based functions, a trailing path separator makes *path*
320+
refer to the directory that a symbolic link points to rather than to the
321+
link itself. For example, ``rmtree('link/')`` deletes the contents of the
322+
directory that ``link`` points to, then reports an error when it tries to
323+
remove ``link/`` itself. The link and the now-empty directory are left in
324+
place.
325+
319326
This function can support :ref:`paths relative to directory descriptors
320327
<dir_fd>`.
321328

0 commit comments

Comments
 (0)