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 authored and naveen521kk committed Nov 2, 2024
1 parent 7326d72 commit 60503cf
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 @@ -379,7 +379,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 @@ -406,7 +406,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 60503cf

Please sign in to comment.