diff options
author | 2024-05-07 12:50:40 +0200 | |
---|---|---|
committer | 2024-05-07 12:50:40 +0200 | |
commit | 6f768b71bab837c6c4aac4d3ddd251e55025fe0b (patch) | |
tree | ad56782e6f858bcfc10409b2e6a1a94d4666dba5 | |
parent | gh-118650: Exclude `_repr_*` methods from Enum's _sunder_ reservation (GH-118... (diff) | |
download | cpython-6f768b71bab837c6c4aac4d3ddd251e55025fe0b.tar.gz cpython-6f768b71bab837c6c4aac4d3ddd251e55025fe0b.tar.bz2 cpython-6f768b71bab837c6c4aac4d3ddd251e55025fe0b.zip |
gh-118119: Re-use `sep` in `posixpath.expanduser()` (GH-118120)
-rw-r--r-- | Lib/posixpath.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/Lib/posixpath.py b/Lib/posixpath.py index f189c3359fb..b4547d7893b 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -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. |