From 172321885586418264b594eb4d09054fc4c1904f Mon Sep 17 00:00:00 2001 From: laurent Date: Wed, 6 Oct 2021 19:58:03 +0100 Subject: [PATCH] Back to hardcoding the method name. --- src/types/function.rs | 8 ++------ tests/test_pyfunction.rs | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/types/function.rs b/src/types/function.rs index c931de52e1d..5867158c40f 100644 --- a/src/types/function.rs +++ b/src/types/function.rs @@ -80,11 +80,7 @@ impl PyCFunction { } /// Create a new function from a closure. - pub fn new_closure<'a, F, R>( - function_name: &'static str, - f: F, - py: Python<'a>, - ) -> PyResult<&'a PyCFunction> + pub fn new_closure(f: F, py: Python) -> PyResult<&PyCFunction> where F: Fn(&types::PyTuple, Option<&types::PyDict>) -> PyResult + Send + 'static, R: crate::callback::IntoPyCallbackOutput<*mut ffi::PyObject>, @@ -98,7 +94,7 @@ impl PyCFunction { ) }; let method_def = methods::PyMethodDef::cfunction_with_keywords( - function_name, + "pyo3-closure", methods::PyCFunctionWithKeywords(run_closure::), "", ); diff --git a/tests/test_pyfunction.rs b/tests/test_pyfunction.rs index 5d0ffdf636c..6c68f4c8612 100644 --- a/tests/test_pyfunction.rs +++ b/tests/test_pyfunction.rs @@ -239,7 +239,7 @@ fn test_closure() { .collect(); Ok(res) }; - let closure_py = PyCFunction::new_closure("closure", f, py).unwrap(); + let closure_py = PyCFunction::new_closure(f, py).unwrap(); py_assert!(py, closure_py, "closure_py(42) == [43]"); py_assert!( @@ -260,7 +260,7 @@ fn test_closure_counter() { *counter += 1; Ok(*counter) }; - let counter_py = PyCFunction::new_closure("counter", counter_fn, py).unwrap(); + let counter_py = PyCFunction::new_closure(counter_fn, py).unwrap(); py_assert!(py, counter_py, "counter_py() == 1"); py_assert!(py, counter_py, "counter_py() == 2");