]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-118119: Re-use `sep` in `posixpath.expanduser()` (GH-118120)
authorNice Zombies <nineteendo19d0@gmail.com>
Tue, 7 May 2024 10:50:40 +0000 (12:50 +0200)
committerGitHub <noreply@github.com>
Tue, 7 May 2024 10:50:40 +0000 (12:50 +0200)
Lib/posixpath.py

index f189c3359fbea64cb37a1684caecb713cccdf9d9..b4547d7893b1cd8a7aee43ffc5e4e75402fa3de6 100644 (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.