diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py index 15c42ca58..3fcedb58e 100644 --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -723,7 +723,6 @@ class BaseTestAPI: self.assertFalse(server.connected) self.assertFalse(server.accepting) - @unittest.skipIf(sys.platform == "win32", "TODO: RUSTPYTHON, Windows-only fail") def test_create_socket(self): s = asyncore.dispatcher() s.create_socket(self.family) diff --git a/vm/Cargo.toml b/vm/Cargo.toml index c43a3cf7e..50f75f61c 100644 --- a/vm/Cargo.toml +++ b/vm/Cargo.toml @@ -144,7 +144,7 @@ version = "0.3" features = [ "winsock2", "handleapi", "ws2def", "std", "winbase", "wincrypt", "fileapi", "processenv", "namedpipeapi", "winnt", "processthreadsapi", "errhandlingapi", "winuser", "synchapi", "wincon", - "impl-default", + "impl-default", "vcruntime" ] [target.'cfg(target_arch = "wasm32")'.dependencies] diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index ae75a8d0c..6533ac463 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -2765,7 +2765,6 @@ pub(crate) use posix::raw_set_inheritable; mod nt { use super::*; use crate::builtins::list::PyListRef; - #[cfg(target_env = "msvc")] use winapi::vc::vcruntime::intptr_t; #[pyattr] @@ -3114,6 +3113,34 @@ mod nt { return Err(err.into_pyexception(vm)); } + #[pyfunction] + fn get_handle_inheritable(handle: intptr_t, vm: &VirtualMachine) -> PyResult { + let mut flags = 0; + if unsafe { winapi::um::handleapi::GetHandleInformation(handle as _, &mut flags) } == 0 { + Err(errno_err(vm)) + } else { + Ok(flags & winapi::um::winbase::HANDLE_FLAG_INHERIT != 0) + } + } + + #[pyfunction] + fn set_handle_inheritable( + handle: intptr_t, + inheritable: bool, + vm: &VirtualMachine, + ) -> PyResult<()> { + use winapi::um::winbase::HANDLE_FLAG_INHERIT; + let flags = if inheritable { HANDLE_FLAG_INHERIT } else { 0 }; + let res = unsafe { + winapi::um::handleapi::SetHandleInformation(handle as _, HANDLE_FLAG_INHERIT, flags) + }; + if res == 0 { + Err(errno_err(vm)) + } else { + Ok(()) + } + } + pub(super) fn support_funcs() -> Vec { Vec::new() }