Skip to content
Merged
Prev Previous commit
Next Next commit
Fix mmap resize to raise OSError instead of SystemError
  • Loading branch information
youknowone committed Mar 20, 2026
commit d7d6f7aa3ef9ee1bdf05f75ff43493a80e02cfd9
1 change: 0 additions & 1 deletion Lib/test/test_mmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions crates/stdlib/src/mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ mod mmap {
fn resize(&self, _newsize: PyIntRef, vm: &VirtualMachine) -> PyResult<()> {
self.check_resizeable(vm)?;
// TODO: implement using mremap on Linux
Err(vm.new_system_error("mmap: resizing not available--no mremap()"))
Err(vm.new_os_error("mmap: resizing not available--no mremap()"))
}

#[cfg(windows)]
Expand All @@ -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;
Expand Down