File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -243,12 +243,11 @@ def expanduser(path):
243
243
# pwd module unavailable, return path unchanged
244
244
return path
245
245
try :
246
- pwent = pwd .getpwnam ( name )
246
+ userhome = pwd .getpwuid ( os . getuid ()). pw_dir
247
247
except KeyError :
248
248
# bpo-10496: if the current user identifier doesn't exist in the
249
249
# password database, return the path unchanged
250
250
return path
251
- userhome = pwent .pw_dir
252
251
else :
253
252
userhome = os .environ ['HOME' ]
254
253
else :
@@ -261,11 +260,12 @@ def expanduser(path):
261
260
if isinstance (name , bytes ):
262
261
name = name .decode ('ascii' )
263
262
try :
264
- userhome = pwd .getpwnam (name ). pw_dir
263
+ pwent = pwd .getpwnam (name )
265
264
except KeyError :
266
265
# bpo-10496: if the user name from the path doesn't exist in the
267
266
# password database, return the path unchanged
268
267
return path
268
+ userhome = pwent .pw_dir
269
269
# if no user home, return the path unchanged on VxWorks
270
270
if userhome is None and sys .platform == "vxworks" :
271
271
return path
You can’t perform that action at this time.
0 commit comments