summaryrefslogtreecommitdiffstats
path: root/Lib/shutil.py
diff options
context:
space:
mode:
authorHynek Schlawack <hs@ox.cx>2012-06-28 10:07:29 (GMT)
committerHynek Schlawack <hs@ox.cx>2012-06-28 10:07:29 (GMT)
commita75cd1ce73f627f12329b782922dfc85387be3cc (patch)
tree461078a872fb285108925cf83c01cd8a6b5cf26a /Lib/shutil.py
parent591c1cca325af53db16b302fac212107d5500ec9 (diff)
downloadcpython-a75cd1ce73f627f12329b782922dfc85387be3cc.zip
cpython-a75cd1ce73f627f12329b782922dfc85387be3cc.tar.gz
cpython-a75cd1ce73f627f12329b782922dfc85387be3cc.tar.bz2
#4489: Don't follow ever symlinks in rmtree
Also added several regression tests.
Diffstat (limited to 'Lib/shutil.py')
-rw-r--r--Lib/shutil.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/shutil.py b/Lib/shutil.py
index 3cafd01..da5a98e 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -380,7 +380,7 @@ def _rmtree_safe_fd(topfd, path, onerror):
for name in names:
fullname = os.path.join(path, name)
try:
- orig_st = os.stat(name, dir_fd=topfd)
+ orig_st = os.stat(name, dir_fd=topfd, follow_symlinks=False)
mode = orig_st.st_mode
except os.error:
mode = 0
@@ -445,7 +445,7 @@ def rmtree(path, ignore_errors=False, onerror=None):
if (stat.S_ISDIR(orig_st.st_mode) and
os.path.samestat(orig_st, os.fstat(fd))):
_rmtree_safe_fd(fd, path, onerror)
- elif (stat.S_ISREG(orig_st.st_mode)):
+ else:
raise NotADirectoryError(20,
"Not a directory: '{}'".format(path))
finally: