host_env: address remaining #8702 review comments · RustPython/RustPython@42bfa07 · GitHub
Skip to content

Commit 42bfa07

Browse files
committed
host_env: address remaining #8702 review comments
Map a missing Windows export to a symbol-load error, keep LoadLibrary's Win32 code on the OSError, drop incomplete UTF-16 pairs when truncating thread names, hide set_name and _get_name off linux/macOS/Windows, and let ssl-rustls enable host_env. Assisted-by: Claude
1 parent 473c39e commit 42bfa07

4 files changed

Lines changed: 55 additions & 21 deletions

File tree

crates/host_env/src/ctypes.rs

Lines changed: 16 additions & 1 deletion

crates/stdlib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ threading = ["rustpython-common/threading", "rustpython-vm/threading"]
1818
sqlite = ["dep:libsqlite3-sys"]
1919
# SSL backends
2020
ssl = ["rustpython-host_env/ssl"]
21-
ssl-rustls = ["__ssl-rustls", "rustls/custom-provider"]
21+
ssl-rustls = ["__ssl-rustls", "host_env", "rustls/custom-provider"]
2222
ssl-openssl = ["ssl", "host_env", "openssl", "openssl-sys", "foreign-types-shared", "rustpython-host_env/native-certs"]
2323
ssl-openssl-vendor = ["ssl-openssl", "openssl/vendored"]
2424
tkinter = ["dep:tk-sys", "dep:tcl-sys", "dep:widestring"]

crates/vm/src/stdlib/_ctypes.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ pub(crate) mod _ctypes {
9494
use super::{PyCArray, PyCData, PyCPointer, PyCSimple, PyCStructure, PyCUnion};
9595
use crate::builtins::{PyType, PyTypeRef};
9696
use crate::class::StaticType;
97+
#[cfg(windows)]
98+
use crate::convert::ToPyException;
9799
use crate::convert::ToPyObject;
98100
use crate::function::{Either, OptionalArg};
99101
use crate::types::Representable;
@@ -427,7 +429,7 @@ pub(crate) mod _ctypes {
427429
let flags = load_flags.unwrap_or(0) as u32;
428430
rustpython_host_env::ctypes::load_library_ex_w(&wide, flags)
429431
.map(|module| module as usize)
430-
.map_err(|error| vm.new_os_error(error.to_string()))
432+
.map_err(|error| error.to_pyexception(vm))
431433
}
432434

433435
#[cfg(not(windows))]
@@ -463,7 +465,7 @@ pub(crate) mod _ctypes {
463465
#[pyfunction(name = "FreeLibrary")]
464466
fn free_library(handle: usize, vm: &VirtualMachine) -> PyResult<()> {
465467
rustpython_host_env::ctypes::free_library(handle as _)
466-
.map_err(|error| vm.new_os_error(error.to_string()))
468+
.map_err(|error| error.to_pyexception(vm))
467469
}
468470

469471
#[cfg(not(windows))]

crates/vm/src/stdlib/_thread.rs

Lines changed: 34 additions & 17 deletions

0 commit comments

Comments
 (0)