Skip to content

Commit ccd4c67

Browse files
committed
Fix CopyFile2 to raise proper OSError subclass
Use std::io::Error::from_raw_os_error instead of vm.new_os_error so that winerror attribute is set and errno-to-exception mapping works (e.g. ERROR_ACCESS_DENIED → PermissionError).
1 parent 2f6fc39 commit ccd4c67

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

crates/vm/src/stdlib/_winapi.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,9 @@ mod _winapi {
19441944
} else {
19451945
hr as u32
19461946
};
1947-
return Err(vm.new_os_error(err as i32));
1947+
return Err(
1948+
std::io::Error::from_raw_os_error(err as i32).to_pyexception(vm),
1949+
);
19481950
}
19491951
Ok(())
19501952
}

0 commit comments

Comments
 (0)