From 6f768b71bab837c6c4aac4d3ddd251e55025fe0b Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Tue, 7 May 2024 12:50:40 +0200 Subject: gh-118119: Re-use `sep` in `posixpath.expanduser()` (GH-118120) --- Lib/posixpath.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Lib/posixpath.py b/Lib/posixpath.py index f189c33..b4547d7 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. -- cgit v0.12