summaryrefslogtreecommitdiffstats
path: root/Lib/ntpath.py
diff options
context:
space:
mode:
authorNice Zombies <nineteendo19d0@gmail.com>2024-05-21 20:36:36 (GMT)
committerGitHub <noreply@github.com>2024-05-21 20:36:36 (GMT)
commitb64182550f73e556344bd754d32e3be5d22a74e1 (patch)
tree094aeaee6451de4a0b897ea0669fd9409250497d /Lib/ntpath.py
parentde8f530841b55885b919677a6938ab33d4a92f20 (diff)
downloadcpython-b64182550f73e556344bd754d32e3be5d22a74e1.zip
cpython-b64182550f73e556344bd754d32e3be5d22a74e1.tar.gz
cpython-b64182550f73e556344bd754d32e3be5d22a74e1.tar.bz2
gh-118507 : Refactor `nt._path_is*` to improve applicability for other cases (GH-118755)
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