Skip to content

Commit 4c83626

Browse files
committed
expanduser: normpath paths coming from env vars
This makes sure we get the same paths as with related functions in pathlib.
1 parent 184e0da commit 4c83626

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Lib/ntpath.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def expanduser(path):
348348
if 'USERPROFILE' in os.environ:
349349
userhome = os.environ['USERPROFILE']
350350
elif not 'HOMEPATH' in os.environ:
351-
return path
351+
return os.path.normpath(path)
352352
else:
353353
try:
354354
drive = os.environ['HOMEDRIVE']
@@ -375,7 +375,7 @@ def expanduser(path):
375375
if isinstance(path, bytes):
376376
userhome = os.fsencode(userhome)
377377

378-
return userhome + path[i:]
378+
return os.path.normpath(userhome) + path[i:]
379379

380380

381381
# Expand paths containing shell variable substitutions.

0 commit comments

Comments
 (0)