summaryrefslogtreecommitdiffstats
path: root/Lib/posixpath.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/posixpath.py')
-rw-r--r--Lib/posixpath.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index 37a2a02..aace2b2 100644
--- a/Lib/posixpath.py
+++ b/Lib/posixpath.py
@@ -257,7 +257,10 @@ def expanduser(path):
userhome = pwent.pw_dir
if isinstance(path, bytes):
userhome = userhome.encode(sys.getfilesystemencoding())
- userhome = userhome.rstrip(sep)
+ root = b'/'
+ else:
+ root = '/'
+ userhome = userhome.rstrip(root) or userhome
return userhome + path[i:]