Skip to content

Commit f4dc046

Browse files
nineteendoSonicField
authored andcommitted
pythongh-118119: Re-use sep in posixpath.expanduser() (pythonGH-118120)
1 parent c89b3d6 commit f4dc046

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Lib/posixpath.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,8 @@ def expanduser(path):
298298
return path
299299
if isinstance(path, bytes):
300300
userhome = os.fsencode(userhome)
301-
root = b'/'
302-
else:
303-
root = '/'
304-
userhome = userhome.rstrip(root)
305-
return (userhome + path[i:]) or root
301+
userhome = userhome.rstrip(sep)
302+
return (userhome + path[i:]) or sep
306303

307304

308305
# Expand paths containing shell variable substitutions.

0 commit comments

Comments
 (0)