summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNice Zombies <nineteendo19d0@gmail.com>2024-05-07 10:50:40 (GMT)
committerGitHub <noreply@github.com>2024-05-07 10:50:40 (GMT)
commit6f768b71bab837c6c4aac4d3ddd251e55025fe0b (patch)
treead56782e6f858bcfc10409b2e6a1a94d4666dba5
parent1e428426c836b9a434810a6b99f70454d3a9611e (diff)
downloadcpython-6f768b71bab837c6c4aac4d3ddd251e55025fe0b.zip
cpython-6f768b71bab837c6c4aac4d3ddd251e55025fe0b.tar.gz
cpython-6f768b71bab837c6c4aac4d3ddd251e55025fe0b.tar.bz2
gh-118119: Re-use `sep` in `posixpath.expanduser()` (GH-118120)
-rw-r--r--Lib/posixpath.py7
1 files 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.