@@ -110,34 +110,34 @@ def join(path, *paths):
110
110
try :
111
111
if not paths :
112
112
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 )
114
114
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 )
116
116
if p_root :
117
117
# Second path is absolute
118
118
if p_drive or not result_drive :
119
119
result_drive = p_drive
120
120
result_root = p_root
121
- result_tail = p_tail
121
+ result_path = p_path
122
122
continue
123
123
elif p_drive and p_drive != result_drive :
124
124
if p_drive .lower () != result_drive .lower ():
125
125
# Different drives => ignore the first path entirely
126
126
result_drive = p_drive
127
127
result_root = p_root
128
- result_tail = p_tail
128
+ result_path = p_path
129
129
continue
130
130
# Same drive in different case
131
131
result_drive = p_drive
132
132
# 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
136
136
## 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
138
138
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
141
141
except (TypeError , AttributeError , BytesWarning ):
142
142
genericpath ._check_arg_types ('join' , path , * paths )
143
143
raise
@@ -233,13 +233,13 @@ def split(p):
233
233
Either part may be empty."""
234
234
p = os .fspath (p )
235
235
seps = _get_bothseps (p )
236
- drive , root , tail = splitroot (p )
236
+ d , r , p = splitroot (p )
237
237
# 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 :
240
240
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
243
243
244
244
245
245
# Split a path in root and extension.
@@ -307,10 +307,10 @@ def ismount(path):
307
307
path = os .fspath (path )
308
308
seps = _get_bothseps (path )
309
309
path = abspath (path )
310
- drive , root , tail = splitroot (path )
310
+ drive , root , rest = splitroot (path )
311
311
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 :
314
314
return True
315
315
if not _getvolumepathname :
316
316
return False
@@ -552,9 +552,9 @@ def normpath(path):
552
552
curdir = '.'
553
553
pardir = '..'
554
554
path = path .replace (altsep , sep )
555
- drive , root , tail = splitroot (path )
555
+ drive , root , path = splitroot (path )
556
556
prefix = drive + root
557
- comps = tail .split (sep )
557
+ comps = path .split (sep )
558
558
i = 0
559
559
while i < len (comps ):
560
560
if not comps [i ] or comps [i ] == curdir :
@@ -796,14 +796,14 @@ def relpath(path, start=None):
796
796
try :
797
797
start_abs = abspath (normpath (start ))
798
798
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 )
801
801
if normcase (start_drive ) != normcase (path_drive ):
802
802
raise ValueError ("path is on mount %r, start on mount %r" % (
803
803
path_drive , start_drive ))
804
804
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 ]
807
807
# Work out how much of the filepath is shared by start and path.
808
808
i = 0
809
809
for e1 , e2 in zip (start_list , path_list ):
@@ -847,23 +847,23 @@ def commonpath(paths):
847
847
curdir = '.'
848
848
849
849
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 ]
851
851
852
852
# Check that all drive letters or UNC paths match. The check is made
853
853
# only now otherwise type errors for mixing strings and bytes would not
854
854
# be caught.
855
- if len ({drive for drive , _ , _ in rootsplits }) != 1 :
855
+ if len ({d for d , _ , _ in drivesplits }) != 1 :
856
856
raise ValueError ("Paths don't have the same drive" )
857
857
858
- if len ({root for _ , root , _ in rootsplits }) != 1 :
858
+ if len ({r for _ , r , _ in drivesplits }) != 1 :
859
859
raise ValueError ("Can't mix absolute and relative paths" )
860
860
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 ]
863
863
864
864
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
867
867
]
868
868
s1 = min (split_paths )
869
869
s2 = max (split_paths )
0 commit comments