aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/ntpath.py
diff options
context:
space:
mode:
authorNice Zombies <nineteendo19d0@gmail.com>2024-05-24 20:04:17 +0200
committerGitHub <noreply@github.com>2024-05-24 19:04:17 +0100
commit96b392df303b2cfaea823afcb462c0b455704ce8 (patch)
tree70a9efffceeb22ccf24dd2afb1c3edeada732c96 /Lib/ntpath.py
parentf0ed1863bd7a0b9d021fb59e156663a7ec553f0e (diff)
downloadcpython-96b392df303b2cfaea823afcb462c0b455704ce8.tar.gz
cpython-96b392df303b2cfaea823afcb462c0b455704ce8.zip
gh-118263: Add additional arguments to path_t (Argument Clinic type) in posixmodule (GH-118355)
Diffstat (limited to 'Lib/ntpath.py')
-rw-r--r--Lib/ntpath.py42
1 files changed, 5 insertions, 37 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index 8d972cd1d0e..83e2d3b8657 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -168,19 +168,12 @@ def splitdrive(p):
try:
- from nt import _path_splitroot_ex
+ from nt import _path_splitroot_ex as splitroot
except ImportError:
def splitroot(p):
- """Split a pathname into drive, root and tail. The drive is defined
- exactly as in splitdrive(). On Windows, the root may be a single path
- separator or an empty string. The tail contains anything after the root.
- For example:
-
- splitroot('//server/share/') == ('//server/share', '/', '')
- splitroot('C:/Users/Barney') == ('C:', '/', 'Users/Barney')
- splitroot('C:///spam///ham') == ('C:', '/', '//spam///ham')
- splitroot('Windows/notepad') == ('', '', 'Windows/notepad')
- """
+ """Split a pathname into drive, root and tail.
+
+ The tail contains anything after the root."""
p = os.fspath(p)
if isinstance(p, bytes):
sep = b'\\'
@@ -220,23 +213,6 @@ except ImportError:
else:
# Relative path, e.g. Windows
return empty, empty, p
-else:
- def splitroot(p):
- """Split a pathname into drive, root and tail. The drive is defined
- exactly as in splitdrive(). On Windows, the root may be a single path
- separator or an empty string. The tail contains anything after the root.
- For example:
-
- splitroot('//server/share/') == ('//server/share', '/', '')
- splitroot('C:/Users/Barney') == ('C:', '/', 'Users/Barney')
- splitroot('C:///spam///ham') == ('C:', '/', '//spam///ham')
- splitroot('Windows/notepad') == ('', '', 'Windows/notepad')
- """
- p = os.fspath(p)
- if isinstance(p, bytes):
- drive, root, tail = _path_splitroot_ex(os.fsdecode(p))
- return os.fsencode(drive), os.fsencode(root), os.fsencode(tail)
- return _path_splitroot_ex(p)
# Split a path in head (everything up to the last '/') and tail (the
@@ -538,7 +514,7 @@ def expandvars(path):
# Previously, this function also truncated pathnames to 8+3 format,
# but as this module is called "ntpath", that's obviously wrong!
try:
- from nt import _path_normpath
+ from nt import _path_normpath as normpath
except ImportError:
def normpath(path):
@@ -577,14 +553,6 @@ except ImportError:
comps.append(curdir)
return prefix + sep.join(comps)
-else:
- def normpath(path):
- """Normalize path, eliminating double slashes, etc."""
- path = os.fspath(path)
- if isinstance(path, bytes):
- return os.fsencode(_path_normpath(os.fsdecode(path))) or b"."
- return _path_normpath(path) or "."
-
def _abspath_fallback(path):
"""Return the absolute version of a path as a fallback function in case