8000 Fix incorrect change · python/cpython@1382f49 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1382f49

Browse files
committed
Fix incorrect change
1 parent 4568cd1 commit 1382f49

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Lib/posixpath.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,11 @@ def expanduser(path):
243243
# pwd module unavailable, return path unchanged
244244
return path
245245
try:
246-
pwent = pwd.getpwnam(name)
246+
userhome = pwd.getpwuid(os.getuid()).pw_dir
247247
except KeyError:
248248
# bpo-10496: if the current user identifier doesn't exist in the
249249
# password database, return the path unchanged
250250
return path
251-
userhome = pwent.pw_dir
252251
else:
253252
userhome = os.environ['HOME']
254253
else:
@@ -261,11 +260,12 @@ def expanduser(path):
261260
if isinstance(name, bytes):
262261
name = name.decode('ascii')
263262
try:
264-
userhome = pwd.getpwnam(name).pw_dir
263+
pwent = pwd.getpwnam(name)
265264
except KeyError:
266265
# bpo-10496: if the user name from the path doesn't exist in the
267266
# password database, return the path unchanged
268267
return path
268+
userhome = pwent.pw_dir
269269
# if no user home, return the path unchanged on VxWorks
270270
if userhome is None and sys.platform == "vxworks":
271271
return path

0 commit comments

Comments
 (0)
0