8000 Fix not throwing the same error as CPython in test_pathlib.test_expanduser by hbina · Pull Request #5578 · RustPython/RustPython · GitHub
[go: up one dir, main page]

Skip to content

Fix not throwing the same error as CPython in test_pathlib.test_expanduser #5578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions extra_tests/snippets/stdlib_pwd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import sys
# windows doesn't support pwd
if sys.platform.startswith("win"):
exit(0)

from testutils import assert_raises
import pwd

with assert_raises(KeyError):
fake_name = 'fake_user'
while pwd.getpwnam(fake_name):
fake_name += '1'
2 changes: 1 addition & 1 deletion vm/src/stdlib/pwd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ mod pwd {
if pw_name.contains('\0') {
return Err(exceptions::cstring_error(vm));
}
let user = User::from_name(name.as_str()).map_err(|err| err.into_pyexception(vm))?;
let user = User::from_name(name.as_str()).ok().flatten();
let user = user.ok_or_else(|| {
vm.new_key_error(
vm.ctx
Expand Down
Loading
0