Skip to content

Commit

Permalink
fix(rust): follow-up API changes in PyO3 0.23
Browse files Browse the repository at this point in the history
  • Loading branch information
vlaci committed Feb 10, 2025
1 parent 226dc51 commit 9fad902
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions rust/src/math_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ pub fn py_chi_square_probability(py: Python, data: &[u8]) -> PyResult<f64> {
}

pub fn init_module(root_module: &Bound<'_, PyModule>) -> PyResult<()> {
let module = PyModule::new_bound(root_module.py(), "math_tools")?;
let module = PyModule::new(root_module.py(), "math_tools")?;
module.add_function(wrap_pyfunction!(py_shannon_entropy, &module)?)?;
module.add_function(wrap_pyfunction!(py_chi_square_probability, &module)?)?;

root_module.add_submodule(&module)?;

root_module
.py()
.import_bound("sys")?
.import("sys")?
.getattr("modules")?
.set_item("unblob._rust.math", module)?;

Expand Down
6 changes: 3 additions & 3 deletions rust/src/sandbox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,18 @@ impl PyAccessFS {
}

pub fn init_module(root_module: &Bound<'_, PyModule>) -> PyResult<()> {
let module = PyModule::new_bound(root_module.py(), "sandbox")?;
let module = PyModule::new(root_module.py(), "sandbox")?;
module.add_function(wrap_pyfunction!(py_restrict_access, &module)?)?;
module.add_class::<PyAccessFS>()?;
module.add(
"SandboxError",
root_module.py().get_type_bound::<PySandboxError>(),
root_module.py().get_type::<PySandboxError>(),
)?;

root_module.add_submodule(&module)?;
root_module
.py()
.import_bound("sys")?
.import("sys")?
.getattr("modules")?
.set_item("unblob._rust.sandbox", module)?;

Expand Down

0 comments on commit 9fad902

Please sign in to comment.