MCPcopy Index your code
hub / github.com/RustPython/RustPython / getpwall

Function getpwall

crates/vm/src/stdlib/pwd.rs:101–116  ·  view source on GitHub ↗
(vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

99 #[cfg(not(target_os = "android"))]
100 #[pyfunction]
101 fn getpwall(vm: &VirtualMachine) -> PyResult<Vec<PyObjectRef>> {
102 // setpwent, getpwent, etc are not thread safe. Could use fgetpwent_r, but this is easier
103 static GETPWALL: parking_lot::Mutex<()> = parking_lot::Mutex::new(());
104 let _guard = GETPWALL.lock();
105 let mut list = Vec::new();
106
107 unsafe { libc::setpwent() };
108 while let Some(ptr) = core::ptr::NonNull::new(unsafe { libc::getpwent() }) {
109 let user = User::from(unsafe { ptr.as_ref() });
110 let passwd = PasswdData::from(user).to_pyobject(vm);
111 list.push(passwd);
112 }
113 unsafe { libc::endpwent() };
114
115 Ok(list)
116 }
117}

Callers 1

test_expanduser_pwd2Method · 0.85

Calls 5

newFunction · 0.85
lockMethod · 0.45
as_refMethod · 0.45
to_pyobjectMethod · 0.45
pushMethod · 0.45

Tested by 1

test_expanduser_pwd2Method · 0.68