Skip to content

Commit e81af12

Browse files
Fix test that uses the pwd exceptions explicitly
Thanks @simpleprogrammer2
1 parent b9e4522 commit e81af12

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Lib/posixpath.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def expanduser(path):
250250
return path
251251
try:
252252
userhome = pwd.getpwuid(os.getuid()).pw_dir
253-
except KeyError:
253+
except (KeyError, OSError):
254254
# bpo-10496: if the current user identifier doesn't exist in the
255255
# password database, return the path unchanged
256256
return path
@@ -267,7 +267,7 @@ def expanduser(path):
267267
name = os.fsdecode(name)
268268
try:
269269
pwent = pwd.getpwnam(name)
270-
except KeyError:
270+
except (KeyError, OSError):
271271
# bpo-10496: if the user name from the path doesn't exist in the
272272
# password database, return the path unchanged
273273
return path

0 commit comments

Comments
 (0)