From 228098ff15b7a9f751bd465cc94f7b8cb593e773 Mon Sep 17 00:00:00 2001 From: Nice Zombies Date: Sat, 20 Apr 2024 09:18:56 +0200 Subject: [PATCH] Re-use `sep` in `posixpath.expanduser()` --- Lib/posixpath.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Lib/posixpath.py b/Lib/posixpath.py index f1960ddb88e590..10dae163b3fe0d 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -278,11 +278,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.