summaryrefslogtreecommitdiffstats
path: root/Lib/ntpath.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-05-22 00:29:34 (GMT)
committerGitHub <noreply@github.com>2024-05-22 00:29:34 (GMT)
commitf15fbe9991b9cb93d0b4c08e9931ac0770c4e40a (patch)
treeef94a830f296172cfcf69e179b1996d372c39193 /Lib/ntpath.py
parentf371565169438c3b93763f298d5171985607ab5d (diff)
downloadcpython-f15fbe9991b9cb93d0b4c08e9931ac0770c4e40a.zip
cpython-f15fbe9991b9cb93d0b4c08e9931ac0770c4e40a.tar.gz
cpython-f15fbe9991b9cb93d0b4c08e9931ac0770c4e40a.tar.bz2
gh-118507 : Refactor `nt._path_is*` to improve applicability for other cases (GH-118755)
(cherry picked from commit b64182550f73e556344bd754d32e3be5d22a74e1) Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Diffstat (limited to 'Lib/ntpath.py')
-rw-r--r--Lib/ntpath.py21
1 files changed, 4 insertions, 17 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index b833e0b..8d972cd 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -288,21 +288,6 @@ def dirname(p):
return split(p)[0]
-# Is a path a junction?
-
-if hasattr(os.stat_result, 'st_reparse_tag'):
- def isjunction(path):
- """Test whether a path is a junction"""
- try:
- st = os.lstat(path)
- except (OSError, ValueError, AttributeError):
- return False
- return st.st_reparse_tag == stat.IO_REPARSE_TAG_MOUNT_POINT
-else:
- # Use genericpath.isjunction as imported above
- pass
-
-
# Is a path a mount point?
# Any drive letter root (eg c:\)
# Any share UNC (eg \\server\share)
@@ -911,13 +896,15 @@ def commonpath(paths):
try:
- # The isdir(), isfile(), islink() and exists() implementations in
- # genericpath use os.stat(). This is overkill on Windows. Use simpler
+ # The isdir(), isfile(), islink(), exists() and lexists() implementations
+ # in genericpath use os.stat(). This is overkill on Windows. Use simpler
# builtin functions if they are available.
from nt import _path_isdir as isdir
from nt import _path_isfile as isfile
from nt import _path_islink as islink
+ from nt import _path_isjunction as isjunction
from nt import _path_exists as exists
+ from nt import _path_lexists as lexists
except ImportError:
# Use genericpath.* as imported above
pass