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

Function sock_from_raw

crates/stdlib/src/socket.rs:3261–3275  ·  view source on GitHub ↗
(fileno: RawSocket, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

3259 }
3260
3261 fn sock_from_raw(fileno: RawSocket, vm: &VirtualMachine) -> PyResult<Socket> {
3262 let invalid = {
3263 cfg_if::cfg_if! {
3264 if #[cfg(windows)] {
3265 fileno == INVALID_SOCKET
3266 } else {
3267 fileno < 0
3268 }
3269 }
3270 };
3271 if invalid {
3272 return Err(vm.new_value_error("negative file descriptor"));
3273 }
3274 Ok(unsafe { sock_from_raw_unchecked(fileno) })
3275 }
3276 /// SAFETY: fileno must not be equal to INVALID_SOCKET
3277 unsafe fn sock_from_raw_unchecked(fileno: RawSocket) -> Socket {
3278 #[cfg(unix)]

Callers 2

_initMethod · 0.85
dupFunction · 0.85

Calls 2

sock_from_raw_uncheckedFunction · 0.85
ErrClass · 0.50

Tested by

no test coverage detected