https://github.com/python/cpython/commit/c393c16b03eb11b9ebc070c68d8d9dcb88732d3c
commit: c393c16b03eb11b9ebc070c68d8d9dcb88732d3c
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: StanFromIreland <[email protected]>
date: 2026-10-23T07:46:02+01:00
summary:
[3.14] gh-160322: document shutil.rmtree("link/") symlink following behavior
(GH-160372) (#160394)
(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 d802a2572871ea..3fcf1bac5d3d7b 100644
--- a/Doc/library/shutil.rst
+++ b/Doc/library/shutil.rst
@@ -316,6 +316,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]