(obj: PyObjectRef, vm: &VirtualMachine)
| 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)] |
no test coverage detected