Skip to content

Commit ba18893

Browse files
gh-87319: Simplify TemporaryDirectory cleanup using os.path.isjunction() (GH-112791)
1 parent 81c16cd commit ba18893

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

Lib/tempfile.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import io as _io
4242
import os as _os
4343
import shutil as _shutil
44-
import stat as _stat
4544
import errno as _errno
4645
from random import Random as _Random
4746
import sys as _sys
@@ -909,18 +908,7 @@ def onexc(func, path, exc):
909908
# raise NotADirectoryError and mask the PermissionError.
910909
# So we must re-raise the current PermissionError if
911910
# path is not a directory.
912-
try:
913-
st = _os.lstat(path)
914-
except OSError:
915-
if ignore_errors:
916-
return
917-
raise
918-
if (_stat.S_ISLNK(st.st_mode) or
919-
not _stat.S_ISDIR(st.st_mode) or
920-
(hasattr(st, 'st_file_attributes') and
921-
st.st_file_attributes & _stat.FILE_ATTRIBUTE_REPARSE_POINT and
922-
st.st_reparse_tag == _stat.IO_REPARSE_TAG_MOUNT_POINT)
923-
):
911+
if not _os.path.isdir(path) or _os.path.isjunction(path):
924912
if ignore_errors:
925913
return
926914
raise

0 commit comments

Comments
 (0)