mirror of
https://github.com/python/cpython.git
synced 2025-07-13 14:25:18 +00:00
bpo-26660, bpo-35144: Fix permission errors in TemporaryDirectory cleanup. (GH-10320)
TemporaryDirectory.cleanup() failed when non-writeable or non-searchable files or directories were created inside a temporary directory.
This commit is contained in:
parent
38ab7d4721
commit
e9b51c0ad8
4 changed files with 86 additions and 14 deletions
|
@ -584,11 +584,16 @@ def _rmtree_safe_fd(topfd, path, onerror):
|
|||
fullname = os.path.join(path, entry.name)
|
||||
try:
|
||||
is_dir = entry.is_dir(follow_symlinks=False)
|
||||
if is_dir:
|
||||
orig_st = entry.stat(follow_symlinks=False)
|
||||
is_dir = stat.S_ISDIR(orig_st.st_mode)
|
||||
except OSError:
|
||||
is_dir = False
|
||||
else:
|
||||
if is_dir:
|
||||
try:
|
||||
orig_st = entry.stat(follow_symlinks=False)
|
||||
is_dir = stat.S_ISDIR(orig_st.st_mode)
|
||||
except OSError:
|
||||
onerror(os.lstat, fullname, sys.exc_info())
|
||||
continue
|
||||
if is_dir:
|
||||
try:
|
||||
dirfd = os.open(entry.name, os.O_RDONLY, dir_fd=topfd)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue