diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-12-07 17:17:27 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-07 17:17:27 (GMT) |
| commit | 418adf687ff1ccdd56cbc0f91d03936f57bf4c77 (patch) | |
| tree | f841670333005c273904f4dc0237aade040d1f6f /Lib/tempfile.py | |
| parent | 6ceb8aeda504b079fef7a57b8d81472f15cdd9a5 (diff) | |
| download | cpython-418adf687ff1ccdd56cbc0f91d03936f57bf4c77.zip cpython-418adf687ff1ccdd56cbc0f91d03936f57bf4c77.tar.gz cpython-418adf687ff1ccdd56cbc0f91d03936f57bf4c77.tar.bz2 | |
[3.12] gh-87319: Simplify TemporaryDirectory cleanup using os.path.isjunction() (GH-112791) (GH-112845)
(cherry picked from commit ba18893555bbf69b1da262aaf85d65e4b67e8955)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/tempfile.py')
| -rw-r--r-- | Lib/tempfile.py | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py index 9a5e7d0..4d99f91 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -41,7 +41,6 @@ import warnings as _warnings 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 @@ -909,18 +908,7 @@ class TemporaryDirectory: # 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 |
