gh-118119: Re-use sep in posixpath.expanduser() (GH-118120)

This commit is contained in:
Nice Zombies 2024-05-07 12:50:40 +02:00 committed by GitHub
parent 1e428426c8
commit 6f768b71ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -298,11 +298,8 @@ def expanduser(path):
return path
if isinstance(path, bytes):
userhome = os.fsencode(userhome)
root = b'/'
else:
root = '/'
userhome = userhome.rstrip(root)
return (userhome + path[i:]) or root
userhome = userhome.rstrip(sep)
return (userhome + path[i:]) or sep
# Expand paths containing shell variable substitutions.