diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index 448ea2325fe..ed96be53cca 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -867,7 +867,6 @@ def test_resize_fails_if_mapping_held_elsewhere(self): finally: f.close() - @unittest.expectedFailure # TODO: RUSTPYTHON @unittest.skipUnless(os.name == 'nt', 'requires Windows') def test_resize_succeeds_with_error_for_second_named_mapping(self): """If a more than one mapping exists of the same name, none of them can diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 824c636dfd1..2ba98616ea6 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1903,7 +1903,6 @@ def test_run_with_pathlike_path_and_arguments(self): res = subprocess.run(args) self.assertEqual(res.returncode, 57) - @unittest.skipIf(mswindows, "TODO: RUSTPYTHON; empty env block fails nondeterministically") @unittest.skipUnless(mswindows, "Maybe test trigger a leak on Ubuntu") def test_run_with_an_empty_env(self): # gh-105436: fix subprocess.run(..., env={}) broken on Windows diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 89987aeba6e..71c2f7512b1 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -878,7 +878,6 @@ def test_sys_flags_no_instantiation(self): def test_sys_version_info_no_instantiation(self): self.assert_raise_on_new_sys_type(sys.version_info) - @unittest.expectedFailure # TODO: RUSTPYTHON; TypeError not raised for getwindowsversion instantiation def test_sys_getwindowsversion_no_instantiation(self): # Skip if not being run on Windows. test.support.get_attribute(sys, "getwindowsversion") diff --git a/crates/stdlib/src/mmap.rs b/crates/stdlib/src/mmap.rs index d441a3dd887..a99d0cc131d 100644 --- a/crates/stdlib/src/mmap.rs +++ b/crates/stdlib/src/mmap.rs @@ -1204,7 +1204,7 @@ mod mmap { // Check if this is a Named mmap - these cannot be resized if let Some(MmapObj::Named(_)) = mmap_guard.as_ref() { - return Err(vm.new_system_error("mmap: cannot resize a named memory mapping")); + return Err(vm.new_os_error("mmap: cannot resize a named memory mapping")); } let is_anonymous = handle == INVALID_HANDLE_VALUE as isize; diff --git a/crates/vm/src/stdlib/_winapi.rs b/crates/vm/src/stdlib/_winapi.rs index 36113f054da..fe2e752b99f 100644 --- a/crates/vm/src/stdlib/_winapi.rs +++ b/crates/vm/src/stdlib/_winapi.rs @@ -445,6 +445,11 @@ mod _winapi { for (_, entry) in entries { out.push(entry); } + // Each entry ends with \0, so one more \0 terminates the block. + // For empty env, we need \0\0 as a valid empty environment block. + if out.is_empty() { + out.push_str("\0"); + } out.push_str("\0"); Ok(out.into_vec()) } diff --git a/crates/vm/src/stdlib/errno.rs b/crates/vm/src/stdlib/errno.rs index 8e4efbaafe9..d7a0a222a76 100644 --- a/crates/vm/src/stdlib/errno.rs +++ b/crates/vm/src/stdlib/errno.rs @@ -39,12 +39,11 @@ pub mod errors { WSAENOMORE, WSAENOPROTOOPT, WSAENOTCONN, WSAENOTEMPTY, WSAENOTSOCK, WSAEOPNOTSUPP, WSAEPFNOSUPPORT, WSAEPROCLIM, WSAEPROTONOSUPPORT, WSAEPROTOTYPE, WSAEPROVIDERFAILEDINIT, WSAEREFUSED, WSAEREMOTE, WSAESHUTDOWN, WSAESOCKTNOSUPPORT, - WSAESTALE, WSAETIMEDOUT, WSAETOOMANYREFS, WSAEUSERS, WSAEWOULDBLOCK, WSAHOST_NOT_FOUND, - WSAID_ACCEPTEX, WSAID_CONNECTEX, WSAID_DISCONNECTEX, WSAID_GETACCEPTEXSOCKADDRS, - WSAID_TRANSMITFILE, WSAID_TRANSMITPACKETS, WSAID_WSAPOLL, WSAID_WSARECVMSG, WSANO_DATA, - WSANO_RECOVERY, WSANOTINITIALISED, WSAPROTOCOL_LEN, WSASERVICE_NOT_FOUND, - WSASYS_STATUS_LEN, WSASYSCALLFAILURE, WSASYSNOTREADY, WSATRY_AGAIN, WSATYPE_NOT_FOUND, - WSAVERNOTSUPPORTED, + WSAESTALE, WSAETIMEDOUT, WSAETOOMANYREFS, WSAEUSERS, WSAEWOULDBLOCK, WSAID_ACCEPTEX, + WSAID_CONNECTEX, WSAID_DISCONNECTEX, WSAID_GETACCEPTEXSOCKADDRS, WSAID_TRANSMITFILE, + WSAID_TRANSMITPACKETS, WSAID_WSAPOLL, WSAID_WSARECVMSG, WSANO_DATA, WSANO_RECOVERY, + WSANOTINITIALISED, WSAPROTOCOL_LEN, WSASERVICE_NOT_FOUND, WSASYS_STATUS_LEN, + WSASYSCALLFAILURE, WSASYSNOTREADY, WSATRY_AGAIN, WSATYPE_NOT_FOUND, WSAVERNOTSUPPORTED, }, }; #[cfg(windows)] @@ -64,8 +63,6 @@ pub mod errors { ETIMEDOUT, ETOOMANYREFS, EUSERS, EWOULDBLOCK, // TODO: EBADF should be here once winerrs are translated to errnos but it messes up some things atm } - #[cfg(windows)] - pub const WSAHOS: i32 = WSAHOST_NOT_FOUND; } #[cfg(any(unix, windows, target_os = "wasi"))] @@ -566,7 +563,7 @@ const ERROR_CODES: &[(&str, i32)] = &[ e!(cfg(windows), WSAEDISCON), e!(cfg(windows), WSAEINTR), e!(cfg(windows), WSAEPROTOTYPE), - e!(cfg(windows), WSAHOS), + // TODO: e!(cfg(windows), WSAHOS), e!(cfg(windows), WSAEADDRINUSE), e!(cfg(windows), WSAEADDRNOTAVAIL), e!(cfg(windows), WSAEALREADY), diff --git a/crates/vm/src/stdlib/sys.rs b/crates/vm/src/stdlib/sys.rs index 33325c9dc60..72379494ddb 100644 --- a/crates/vm/src/stdlib/sys.rs +++ b/crates/vm/src/stdlib/sys.rs @@ -1807,7 +1807,12 @@ mod sys { #[cfg(windows)] #[pyclass(with(PyStructSequence))] - impl PyWindowsVersion {} + impl PyWindowsVersion { + #[pyslot] + fn slot_new(_cls: PyTypeRef, _args: FuncArgs, vm: &VirtualMachine) -> PyResult { + Err(vm.new_type_error("cannot create 'sys.getwindowsversion' instances")) + } + } #[derive(Debug)] #[pystruct_sequence_data(try_from_object)]