diff --git a/Cargo.lock b/Cargo.lock index b2a7afb..aeb0581 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -291,9 +291,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.20.3" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53bdbb96d49157e65d45cc287af5f32ffadd5f4761438b527b055fb0d4bb8233" +checksum = "a02a88a17e74cadbc8ce77855e1d6c8ad0ab82901a4a9b5046bd01c1c0bd95cd" dependencies = [ "cfg-if", "indoc", @@ -309,9 +309,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.20.3" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deaa5745de3f5231ce10517a1f5dd97d53e5a2fd77aa6b5842292085831d48d7" +checksum = "a5eb0b6ecba38961f6f4bd6cd5906dfab3cd426ff37b2eed5771006aa31656f1" dependencies = [ "once_cell", "target-lexicon", @@ -319,9 +319,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.20.3" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b42531d03e08d4ef1f6e85a2ed422eb678b8cd62b762e53891c05faf0d4afa" +checksum = "ba8a6e48a29b5d22e4fdaf132d8ba8d3203ee9f06362d48f244346902a594ec3" dependencies = [ "libc", "pyo3-build-config", @@ -329,9 +329,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.20.3" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7305c720fa01b8055ec95e484a6eca7a83c841267f0dd5280f0c8b8551d2c158" +checksum = "4e80493c5965f94a747d0782a607b2328a4eea5391327b152b00e2f3b001cede" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -341,9 +341,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.20.3" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c7e9b68bb9c3149c5b0cade5d07f953d6d125eb4337723c4ccdb665f1f96185" +checksum = "fcd7d86f42004025200e12a6a8119bd878329e6fddef8178eaafa4e4b5906c5b" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 664cfc3..fa92a66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"] } diff --git a/pyproject.toml b/pyproject.toml index 07dd28c..19e5d9e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,6 @@ [build-system] requires = ["maturin>=1.0,<2.0"] build-backend = "maturin" + +[tool.maturin] +features = ["pyo3/extension-module"] diff --git a/src/lib.rs b/src/lib.rs index 4571945..b408fd6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, @@ -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), ], )), ); @@ -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) -> PyResult<()> { m.add("__version__", env!("CARGO_PKG_VERSION"))?; m.add_function(wrap_pyfunction!(clean, m)?)?; m.add_function(wrap_pyfunction!(clean_text, m)?)?;