Skip to content

Commit

Permalink
[3.12] pythongh-87319: Simplify TemporaryDirectory cleanup using os.p…
Browse files Browse the repository at this point in the history
…ath.isjunction() (pythonGH-112791) (pythonGH-112845)

(cherry picked from commit ba18893)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
  • Loading branch information
miss-islington and serhiy-storchaka authored Dec 7, 2023
1 parent 6ceb8ae commit 418adf6
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions Lib/tempfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import io as _io
import os as _os
import shutil as _shutil
import stat as _stat
import errno as _errno
from random import Random as _Random
import sys as _sys
Expand Down Expand Up @@ -909,18 +908,7 @@ def onexc(func, path, exc):
# raise NotADirectoryError and mask the PermissionError.
# So we must re-raise the current PermissionError if
# path is not a directory.
try:
st = _os.lstat(path)
except OSError:
if ignore_errors:
return
raise
if (_stat.S_ISLNK(st.st_mode) or
not _stat.S_ISDIR(st.st_mode) or
(hasattr(st, 'st_file_attributes') and
st.st_file_attributes & _stat.FILE_ATTRIBUTE_REPARSE_POINT and
st.st_reparse_tag == _stat.IO_REPARSE_TAG_MOUNT_POINT)
):
if not _os.path.isdir(path) or _os.path.isjunction(path):
if ignore_errors:
return
raise
Expand Down

0 comments on commit 418adf6

Please sign in to comment.