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

Function urandom

crates/vm/src/stdlib/os.rs:1587–1594  ·  view source on GitHub ↗
(size: isize, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1585
1586 #[pyfunction]
1587 fn urandom(size: isize, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
1588 if size < 0 {
1589 return Err(vm.new_value_error("negative argument not allowed"));
1590 }
1591 let mut buf = vec![0u8; size as usize];
1592 getrandom::fill(&mut buf).map_err(|e| io::Error::from(e).into_pyexception(vm))?;
1593 Ok(buf)
1594 }
1595
1596 #[pyfunction]
1597 pub fn isatty(fd: i32) -> bool {

Callers

nothing calls this directly

Calls 3

fillFunction · 0.85
ErrClass · 0.50
into_pyexceptionMethod · 0.45

Tested by

no test coverage detected