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

Function get_raw_sock

crates/stdlib/src/socket.rs:906–921  ·  view source on GitHub ↗
(obj: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

904 use windows_sys::Win32::NetworkManagement::IpHelper;
905
906 fn get_raw_sock(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<RawSocket> {
907 #[cfg(unix)]
908 type CastFrom = libc::c_long;
909 #[cfg(windows)]
910 type CastFrom = libc::c_longlong;
911
912 // should really just be to_index() but test_socket tests the error messages explicitly
913 if obj.fast_isinstance(vm.ctx.types.float_type) {
914 return Err(vm.new_type_error("integer argument expected, got float"));
915 }
916 let int = obj
917 .try_index_opt(vm)
918 .unwrap_or_else(|| Err(vm.new_type_error("an integer is required")))?;
919 int.try_to_primitive::<CastFrom>(vm)
920 .map(|sock| sock as RawSocket)
921 }
922
923 #[cfg(target_os = "linux")]
924 #[derive(FromArgs)]

Callers 3

_initMethod · 0.85
dupFunction · 0.85
closeFunction · 0.85

Calls 4

fast_isinstanceMethod · 0.80
try_index_optMethod · 0.80
ErrClass · 0.50
mapMethod · 0.45

Tested by

no test coverage detected