8000 Revert renaming · python/cpython@d35783c · GitHub
[go: up one dir, main page]

Skip to content

Commit d35783c

Browse files
committed
Revert renaming
1 parent 7c9dcae commit d35783c

File tree

2 files changed

+46
-46
lines changed

2 files changed

+46
-46
lines changed

Lib/ntpath.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -110,34 +110,34 @@ def join(path, *paths):
110110
try:
111111
if not paths:
112112
path[:0] + sep #23780: Ensure compatible data type even if p is null.
113-
result_drive, result_root, result_tail = splitroot(path)
113+
result_drive, result_root, result_path = splitroot(path)
114114
for p in map(os.fspath, paths):
115-
p_drive, p_root, p_tail = splitroot(p)
115+
p_drive, p_root, p_path = splitroot(p)
116116
if p_root:
117117
# Second path is absolute
118118
if p_drive or not result_drive:
119119
result_drive = p_drive
120120
result_root = p_root
121-
result_tail = p_tail
121+
result_path = p_path
122122
continue
123123
elif p_drive and p_drive != result_drive:
124124
if p_drive.lower() != result_drive.lower():
125125
# Different drives => ignore the first path entirely
126126
result_drive = p_drive
127127
result_root = p_root
128-
result_tail = p_tail
128+
result_path = p_path
129129
continue
130130
# Same drive in different case
131131
result_drive = p_drive
132132
# Second path is relative to the first
133-
if result_tail and result_tail[-1] not in seps:
134-
result_tail = result_tail + sep
135-
result_tail = result_tail + p_tail
133+
if result_path and result_path[-1] not in seps:
134+
result_path = result_path + sep
135+
result_path = result_path + p_path
136136
## add separator between UNC and non-absolute path
137-
if (result_tail and not result_root and
137+
if (result_path and not result_root and
138138
result_drive and result_drive[-1] not in colon + seps):
139-
return result_drive + sep + result_tail
140-
return result_drive + result_root + result_tail
139+
return result_drive + sep + result_path
140+
return result_drive + result_root + result_path
141141
except (TypeError, AttributeError, BytesWarning):
142142
genericpath._check_arg_types('join', path, *paths)
143143
raise
@@ -233,13 +233,13 @@ def split(p):
233233
Either part may be empty."""
234234
p = os.fspath(p)
235235
seps = _get_bothseps(p)
236-
drive, root, tail = splitroot(p)
236+
d, r, p = splitroot(p)
237237
# set i to index beyond p's last slash
238-
i = len(tail)
239-
while i and tail[i-1] not in seps:
238+
i = len(p)
239+
while i and p[i-1] not in seps:
240240
i -= 1
241-
head, tail = tail[:i], tail[i:] # now tail has no slashes
242-
return drive + root + head.rstrip(seps), tail
241+
head, p = p[:i], p[i:] # now tail has no slashes
242+
return d + r + head.rstrip(seps), p
243243

244244

245245
# Split a path in root and extension.
@@ -307,10 +307,10 @@ def ismount(path):
307307
path = os.fspath(path)
308308
seps = _get_bothseps(path)
309309
path = abspath(path)
310-
drive, root, tail = splitroot(path)
310+
drive, root, rest = splitroot(path)
311311
if drive and drive[0] in seps:
312-
return not tail
313-
if root and not tail:
312+
return not rest
313+
if root and not rest:
314314
return True
315315
if not _getvolumepathname:
316316
return False
@@ -552,9 +552,9 @@ def normpath(path):
552552
curdir = '.'
553553
pardir = '..'
554554
path = path.replace(altsep, sep)
555-
drive, root, tail = splitroot(path)
555+
drive, root, path = splitroot(path)
556556
prefix = drive + root
557-
comps = tail.split(sep)
557+
comps = path.split(sep)
558558
i = 0
559559
while i < len(comps):
560560
if not comps[i] or comps[i] == curdir:
@@ -796,14 +796,14 @@ def relpath(path, start=None):
796796
try:
797797
start_abs = abspath(normpath(start))
798798
path_abs = abspath(normpath(path))
799-
start_drive, _, start_tail = splitroot(start_abs)
800-
path_drive, _, path_tail = splitroot(path_abs)
799+
start_drive, _, start_rest = splitroot(start_abs)
800+
path_drive, _, path_rest = splitroot(path_abs)
801801
if normcase(start_drive) != normcase(path_drive):
802802
raise ValueError("path is on mount %r, start on mount %r" % (
803803
path_drive, start_drive))
804804

805-
start_list = [x for x in start_tail.split(sep) if x]
806-
path_list = [x for x in path_tail.split(sep) if x]
805+
start_list = [x for x in start_rest.split(sep) if x]
806+
path_list = [x for x in path_rest.split(sep) if x]
807807
# Work out how much of the filepath is shared by start and path.
808808
i = 0
809809
for e1, e2 in zip(start_list, path_list):
@@ -847,23 +847,23 @@ def commonpath(paths):
847847
curdir = '.'
848848

849849
try:
850-
rootsplits = [splitroot(p.replace(altsep, sep).lower()) for p in paths]
850+
drivesplits = [splitroot(p.replace(altsep, sep).lower()) for p in paths]
851851

852852
# Check that all drive letters or UNC paths match. The check is made
853853
# only now otherwise type errors for mixing strings and bytes would not
854854
# be caught.
855-
if len({drive for drive, _, _ in rootsplits}) != 1:
855+
if len({d for d, _, _ in drivesplits}) != 1:
856856
raise ValueError("Paths don't have the same drive")
857857

858-
if len({root for _, root, _ in rootsplits}) != 1:
858+
if len({r for _, r, _ in drivesplits}) != 1:
859859
raise ValueError("Can't mix absolute and relative paths")
860860

861-
drive, root, tail = splitroot(paths[0].replace(altsep, sep))
862-
common = [c for c in tail.split(sep) if c and c != curdir]
861+
drive, root, path = splitroot(paths[0].replace(altsep, sep))
862+
common = [c for c in path.split(sep) if c and c != curdir]
863863

864864
split_paths = [
865-
[c for c in tail.split(sep) if c and c != curdir]
866-
for _, _, tail in rootsplits
865+
[c for c in p.split(sep) if c and c != curdir]
866+
for _, _, p in drivesplits
867867
]
868868
s1 = min(split_paths)
869869
s2 = max(split_paths)

Lib/posixpath.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -333,25 +333,25 @@ def _normpath_fallback(path):
333333
path = os.fspath(path)
334334
if isinstance(path, bytes):
335335
sep = b'/'
336-
curdir = b'.'
337-
pardir = b'..'
336+
dot = b'.'
337+
dotdot = b'..'
338338
else:
339339
sep = '/'
340-
curdir = '.'
341-
pardir = '..'
340+
dot = '.'
341+
dotdot = '..'
342342
if not path:
343-
return curdir
344-
_, root, tail = splitroot(path)
345-
comps = []
346-
for comp in tail.split(sep):
347-
if not comp or comp == curdir:
343+
return dot
344+
_, initial_slashes, path = splitroot(path)
345+
new_comps = []
346+
for comp in path.split(sep):
347+
if not comp or comp == dot:
348348
continue
349-
if (comp != pardir or (not root and not comps) or
350-
(comps and comps[-1] == pardir)):
351-
comps.append(comp)
352-
elif comps:
353-
comps.pop()
354-
return (root + sep.join(comps)) or curdir
349+
if (comp != dotdot or (not initial_slashes and not new_comps) or
350+
(new_comps and new_comps[-1] == dotdot)):
351+
new_comps.append(comp)
352+
elif new_comps:
353+
new_comps.pop()
354+
return (initial_slashes + sep.join(new_comps)) or dot
355355

356356
try:
357357
from posix import _path_normpath

0 commit comments

Comments
 (0)
0