Skip to content

Commit

Permalink
Revert back to wrap_pyfunction!
Browse files Browse the repository at this point in the history
  • Loading branch information
LilyFoote committed Feb 27, 2024
1 parent df1da21 commit f7a4e82
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion guide/src/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down
2 changes: 1 addition & 1 deletion guide/src/python_from_rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")?;
Expand Down
2 changes: 1 addition & 1 deletion pyo3-macros-backend/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ fn process_functions_in_module(options: &PyModuleOptions, func: &mut syn::ItemFn
let name = &func.sig.ident;
let statements: Vec<syn::Stmt> = 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);
}
Expand Down
5 changes: 2 additions & 3 deletions tests/test_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down Expand Up @@ -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(())
}

Expand Down

0 comments on commit f7a4e82

Please # to comment.