https://github.com/python/cpython/commit/6f768b71bab837c6c4aac4d3ddd251e55025fe0b
commit: 6f768b71bab837c6c4aac4d3ddd251e55025fe0b
branch: main
author: Nice Zombies <[email protected]>
committer: encukou <[email protected]>
date: 2024-05-07T12:50:40+02:00
summary:
gh-118119: Re-use `sep` in `posixpath.expanduser()` (GH-118120)
files:
M Lib/posixpath.py
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index f189c3359fbea6..b4547d7893b1cd 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.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]