From: Nice Zombies Date: Tue, 7 May 2024 10:50:40 +0000 (+0200) Subject: gh-118119: Re-use `sep` in `posixpath.expanduser()` (GH-118120) X-Git-Tag: v3.13.0b1~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6f768b71bab837c6c4aac4d3ddd251e55025fe0b;p=thirdparty%2FPython%2Fcpython.git gh-118119: Re-use `sep` in `posixpath.expanduser()` (GH-118120) --- diff --git a/Lib/posixpath.py b/Lib/posixpath.py index f189c3359fbe..b4547d7893b1 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.