From def35435ee4001f8aedac01b559bb0dc2d0aab00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Fran=C3=A7ois=20Natali?= Date: Fri, 29 Jul 2011 18:59:24 +0200 Subject: Issue #12464: tempfile.TemporaryDirectory.cleanup() should not follow symlinks: fix it. Patch by Petri Lehtinen. --- Lib/tempfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Lib/tempfile.py') diff --git a/Lib/tempfile.py b/Lib/tempfile.py index b28d91f87e..48b77a87e2 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -661,6 +661,7 @@ class TemporaryDirectory(object): _listdir = staticmethod(_os.listdir) _path_join = staticmethod(_os.path.join) _isdir = staticmethod(_os.path.isdir) + _islink = staticmethod(_os.path.islink) _remove = staticmethod(_os.remove) _rmdir = staticmethod(_os.rmdir) _os_error = _os.error @@ -672,7 +673,7 @@ class TemporaryDirectory(object): for name in self._listdir(path): fullname = self._path_join(path, name) try: - isdir = self._isdir(fullname) + isdir = self._isdir(fullname) and not self._islink(fullname) except self._os_error: isdir = False if isdir: -- cgit v1.2.1