Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2230d6c

Browse filesBrowse files
hbinayouknowone
andauthored
Fix not throwing the same error as CPython in test_pathlib.test_expanduser (#5578)
* Fix not throwing the same error as CPython when trying to expanduser of a non-existent user Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com> * add pwd test * Skip pwd test on windows --------- Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com> Co-authored-by: Jeong YunWon <jeong@youknowone.org> Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
1 parent d800a6b commit 2230d6c
Copy full SHA for 2230d6c

File tree

2 files changed

+13
-1
lines changed
Filter options

2 files changed

+13
-1
lines changed

‎extra_tests/snippets/stdlib_pwd.py

Copy file name to clipboard
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import sys
2+
# windows doesn't support pwd
3+
if sys.platform.startswith("win"):
4+
exit(0)
5+
6+
from testutils import assert_raises
7+
import pwd
8+
9+
with assert_raises(KeyError):
10+
fake_name = 'fake_user'
11+
while pwd.getpwnam(fake_name):
12+
fake_name += '1'

‎vm/src/stdlib/pwd.rs

Copy file name to clipboardExpand all lines: vm/src/stdlib/pwd.rs
+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ mod pwd {
5959
if pw_name.contains('\0') {
6060
return Err(exceptions::cstring_error(vm));
6161
}
62-
let user = User::from_name(name.as_str()).map_err(|err| err.into_pyexception(vm))?;
62+
let user = User::from_name(name.as_str()).ok().flatten();
6363
let user = user.ok_or_else(|| {
6464
vm.new_key_error(
6565
vm.ctx

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.