Skip to content

Commit

Permalink
expanduser: normpath paths coming from env vars
Browse files Browse the repository at this point in the history
This makes sure we get the same paths as with related functions in pathlib.
  • Loading branch information
lazka committed Jul 19, 2023
1 parent fdd0d90 commit c94b7ab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Lib/ntpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def expanduser(path):
if 'USERPROFILE' in os.environ:
userhome = os.environ['USERPROFILE']
elif not 'HOMEPATH' in os.environ:
return path
return os.path.normpath(path)
else:
try:
drive = os.environ['HOMEDRIVE']
Expand All @@ -375,7 +375,7 @@ def expanduser(path):
if isinstance(path, bytes):
userhome = os.fsencode(userhome)

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


# Expand paths containing shell variable substitutions.
Expand Down

0 comments on commit c94b7ab

Please sign in to comment.