From f7a4e825bad6c5a047019aca495ed4cf9f29f193 Mon Sep 17 00:00:00 2001 From: Lily Foote Date: Tue, 27 Feb 2024 10:25:12 +0000 Subject: [PATCH] Revert back to wrap_pyfunction! --- guide/src/module.md | 2 +- guide/src/python_from_rust.md | 2 +- pyo3-macros-backend/src/module.rs | 2 +- tests/test_module.rs | 5 ++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/guide/src/module.md b/guide/src/module.md index 91a3d9b9730..53c390bec06 100644 --- a/guide/src/module.md +++ b/guide/src/module.md @@ -79,7 +79,7 @@ fn parent_module(py: Python<'_>, m: &PyModule) -> PyResult<()> { fn register_child_module(py: Python<'_>, parent_module: &PyModule) -> PyResult<()> { let child_module = PyModule::new_bound(py, "child_module")?; - child_module.add_function(wrap_pyfunction_bound!(func, &child_module)?)?; + child_module.add_function(wrap_pyfunction!(func, &child_module)?)?; parent_module.add_submodule(child_module.as_gil_ref())?; Ok(()) } diff --git a/guide/src/python_from_rust.md b/guide/src/python_from_rust.md index cb9c50919b6..b51bbe592eb 100644 --- a/guide/src/python_from_rust.md +++ b/guide/src/python_from_rust.md @@ -311,7 +311,7 @@ fn main() -> PyResult<()> { Python::with_gil(|py| { // Create new module let foo_module = PyModule::new_bound(py, "foo")?; - foo_module.add_function(wrap_pyfunction_bound!(add_one, &foo_module)?)?; + foo_module.add_function(wrap_pyfunction!(add_one, &foo_module)?)?; // Import and get sys.modules let sys = PyModule::import_bound(py, "sys")?; diff --git a/pyo3-macros-backend/src/module.rs b/pyo3-macros-backend/src/module.rs index 461ca0b586d..0c83e842433 100644 --- a/pyo3-macros-backend/src/module.rs +++ b/pyo3-macros-backend/src/module.rs @@ -277,7 +277,7 @@ fn process_functions_in_module(options: &PyModuleOptions, func: &mut syn::ItemFn let name = &func.sig.ident; let statements: Vec = syn::parse_quote! { #wrapped_function - #module_name.as_borrowed().add_function(#krate::wrap_pyfunction_bound!(#name, #module_name.as_borrowed())?)?; + #module_name.as_borrowed().add_function(#krate::wrap_pyfunction!(#name, #module_name.as_borrowed())?)?; }; stmts.extend(statements); } diff --git a/tests/test_module.rs b/tests/test_module.rs index c5be730548a..5763043e57d 100644 --- a/tests/test_module.rs +++ b/tests/test_module.rs @@ -240,7 +240,7 @@ fn subfunction() -> String { } fn submodule(module: &Bound<'_, PyModule>) -> PyResult<()> { - module.add_function(wrap_pyfunction_bound!(subfunction, module)?)?; + module.add_function(wrap_pyfunction!(subfunction, module)?)?; Ok(()) } @@ -306,8 +306,7 @@ fn vararg_module(_py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { ext_vararg_fn(py, a, args) } - m.add_function(wrap_pyfunction_bound!(ext_vararg_fn, m)?) - .unwrap(); + m.add_function(wrap_pyfunction!(ext_vararg_fn, m)?).unwrap(); Ok(()) }