https://github.com/python/cpython/commit/d4f5fdf123295427ef0cdf19548376c3b2ff65f5 commit: d4f5fdf123295427ef0cdf19548376c3b2ff65f5 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: serhiy-storchaka <[email protected]> date: 2026-08-31T14:36:36Z summary:
[3.13] gh-156707: Do not follow junctions in os_helper.rmtree() on Windows (GH-156710) (GH-156716) os.lstat() reports a junction as a directory, so the junction was followed and files in the directory it points to could be removed. Now the junction itself is removed, as in os.walk() and shutil.rmtree(). (cherry picked from commit d87ee279a1f6dfdb478ede5f0ba0360123d85916) Co-authored-by: Serhiy Storchaka <[email protected]> files: M Lib/test/support/os_helper.py diff --git a/Lib/test/support/os_helper.py b/Lib/test/support/os_helper.py index 3bd177ba7d497dd..42898f2b4ea571a 100644 --- a/Lib/test/support/os_helper.py +++ b/Lib/test/support/os_helper.py @@ -406,7 +406,10 @@ def _rmtree_inner(path): file=sys.__stderr__) mode = 0 if stat.S_ISDIR(mode): - _waitfor(_rmtree_inner, fullname, waitall=True) + # Do not follow junctions, which os.lstat() reports + # as directories. + if not os.path.isjunction(fullname): + _waitfor(_rmtree_inner, fullname, waitall=True) _force_run(fullname, os.rmdir, fullname) else: _force_run(fullname, os.unlink, fullname) _______________________________________________ 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]
