https://github.com/python/cpython/commit/97442dc4d1ab1f8733ec56c72477e3323cb78808
commit: 97442dc4d1ab1f8733ec56c72477e3323cb78808
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: StanFromIreland <[email protected]>
date: 2026-10-23T07:45:56+01:00
summary:
[3.15] gh-160322: document shutil.rmtree("link/") symlink following behavior
(GH-160372) (#160393)
(cherry picked from commit 2c24bc1b6ea3fa135634db9d0c336d67b1d42ef9)
Co-authored-by: Gregory P. Smith <[email protected]>
files:
M Doc/library/shutil.rst
diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst
index 6febc7a187a15f..369cd5e1a71481 100644
--- a/Doc/library/shutil.rst
+++ b/Doc/library/shutil.rst
@@ -313,6 +313,12 @@ Directory and files operations
handled by calling a handler specified by *onexc* or *onerror* or, if both
are omitted, exceptions are propagated to the caller.
+ If *path* is a symbolic link to a directory followed by a trailing path
+ separator, such as ``'link/'``, the operating system resolves the link, so
+ :func:`!rmtree` deletes the contents of the directory it points to and then
+ fails to remove *path* itself. :class:`pathlib.Path` strips trailing
+ separators, so ``rmtree(Path('link/'))`` refuses the link as usual.
+
This function can support :ref:`paths relative to directory descriptors
<dir_fd>`.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]