Skip to content

Commit

Permalink
Upgrade pyo3 to 0.21
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Mar 26, 2024
1 parent d40df61 commit 84c99cd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ crate-type = ["cdylib"]

[dependencies]
ammonia = "4.0.0"
pyo3 = { version = "0.20.2", features = ["abi3-py37", "extension-module"] }
pyo3 = { version = "0.21.0", features = ["abi3-py37", "gil-refs"] }
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[build-system]
requires = ["maturin>=1.0,<2.0"]
build-backend = "maturin"

[tool.maturin]
features = ["pyo3/extension-module"]
22 changes: 11 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ fn clean(
if let Some(callback) = attribute_filter {
cleaner.attribute_filter(move |element, attribute, value| {
Python::with_gil(|py| {
let res = callback.call(
let res = callback.call_bound(
py,
PyTuple::new(
PyTuple::new_bound(
py,
[
PyString::new(py, element),
PyString::new(py, attribute),
PyString::new(py, value),
PyString::new_bound(py, element),
PyString::new_bound(py, attribute),
PyString::new_bound(py, value),
],
),
None,
Expand All @@ -154,14 +154,14 @@ fn clean(
}
Err(err) => err,
};
err.write_unraisable(
err.write_unraisable_bound(
py,
Some(PyTuple::new(
Some(&PyTuple::new_bound(
py,
[
PyString::new(py, element),
PyString::new(py, attribute),
PyString::new(py, value),
PyString::new_bound(py, element),
PyString::new_bound(py, attribute),
PyString::new_bound(py, value),
],
)),
);
Expand Down Expand Up @@ -231,7 +231,7 @@ fn is_html(py: Python, html: &str) -> bool {

/// Python bindings to the ammonia HTML sanitization library ( https://github.com/rust-ammonia/ammonia ).
#[pymodule]
fn nh3(_py: Python, m: &PyModule) -> PyResult<()> {
fn nh3(_py: Python, m: &Bound<PyModule>) -> PyResult<()> {
m.add("__version__", env!("CARGO_PKG_VERSION"))?;
m.add_function(wrap_pyfunction!(clean, m)?)?;
m.add_function(wrap_pyfunction!(clean_text, m)?)?;
Expand Down

0 comments on commit 84c99cd

Please sign in to comment.