8000 Revert insignificant changes · python/cpython@4568cd1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4568cd1

Browse files
committed
Revert insignificant changes
1 parent 33259d9 commit 4568cd1

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

Lib/ntpath.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -876,8 +876,12 @@ def commonpath(paths):
876876
s2 = max(split_paths)
877877
for i, c in enumerate(s1):
878878
if c != s2[i]:
879-
return drive + root + sep.join(common[:i])
880-
return drive + root + sep.join(common[:len(s1)])
879+
common = common[:i]
880+
break
881+
else:
882+
common = common[:len(s1)]
883+
884+
return drive + root + sep.join(common)
881885
except (TypeError, AttributeError):
882886
genericpath._check_arg_types('commonpath', *paths)
883887
raise

Lib/posixpath.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,12 @@ def split(p):
117117
def splitext(p):
118118
p = os.fspath(p)
119119
if isinstance(p, bytes):
120-
return genericpath._splitext(p, b'/', None, b'.')
120+
sep = b'/'
121+
extsep = b'.'
121122
else:
122-
return genericpath._splitext(p, '/', None, '.')
123+
sep = '/'
124+
extsep = '.'
125+
return genericpath._splitext(p, sep, None, extsep)
123126
splitext.__doc__ = genericpath._splitext.__doc__
124127

125128
# Split a pathname into a drive specification and the rest of the
@@ -240,11 +243,12 @@ def expanduser(path):
240243
# pwd module unavailable, return path unchanged
241244
return path
242245
try:
243-
userhome = pwd.getpwuid(os.getuid()).pw_dir
246+
pwent = pwd.getpwnam(name)
244247
except KeyError:
245248
# bpo-10496: if the current user identifier doesn't exist in the
246249
# password database, return the path unchanged
247250
return path
251+
userhome = pwent.pw_dir
248252
else:
249253
userhome = os.environ['HOME']
250254
else:
@@ -352,16 +356,19 @@ def normpath(path):
352356
if not path:
353357
return dot
354358
_, initial_slashes, path = splitroot(path)
359+
comps = path.split(sep)
355360
new_comps = []
356-
for comp in path.split(sep):
361+
for comp in comps:
357362
if not comp or comp == dot:
358363
continue
359364
if (comp != dotdot or (not initial_slashes and not new_comps) or
360365
(new_comps and new_comps[-1] == dotdot)):
361366
new_comps.append(comp)
362367
elif new_comps:
363368
new_comps.pop()
364-
return (initial_slashes + sep.join(new_comps)) or dot
369+
comps = new_comps
370+
path = initial_slashes + sep.join(comps)
371+
return path or dot
365372
else:
366373
def normpath(path):
367374
"""Normalize path, eliminating double slashes, etc."""

0 commit comments

Comments
 (0)
0