This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: shutil.rmtree follows junctions on windows
Type: Stage: resolved
Components: IO, Windows Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Jordan Hueckstaedt, eryksun, iritkatriel, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2019-04-12 20:35 by Jordan Hueckstaedt, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg340111 - (view) Author: Jordan Hueckstaedt (Jordan Hueckstaedt) Date: 2019-04-12 20:35
shutil.rmtree follows junctions / reparse points on windows and will delete files in the target link directory.
msg396158 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-06-20 00:14
The documentation for rmtree[1] now says:

Changed in version 3.8: On Windows, will no longer delete the contents of a directory junction before removing the junction.

So I think this issue can be closed.

[1] https://docs.python.org/3/library/shutil.html#shutil.rmtree
msg396163 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2021-06-20 06:34
Yes, this issue is out of date. shutil._rmtree_isdir() and shutil._rmtree_islink() were added to handle mount points (i.e. junctions) as if they're symlinks. 

More generally, junctions and symlinks are what the platform refers to as name-surrogate reparse points. This category isn't handled generically by rmtree(). It wouldn't be hard to generalize the implementation, but that's something for a new issue.
History
Date User Action Args
2022-04-11 14:59:13adminsetgithub: 80802
2021-06-20 06:34:47eryksunsetstatus: pending -> closed

nosy: + eryksun
messages: + msg396163

stage: resolved
2021-06-20 00:14:45iritkatrielsetstatus: open -> pending

nosy: + iritkatriel
messages: + msg396158

resolution: out of date
2019-04-12 20:35:45Jordan Hueckstaedtcreate