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.