From c519b4de765afd4c91118ba5201f355395a919d7 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Thu, 10 Sep 2020 21:33:17 +0100 Subject: [PATCH] Fix build for new apis --- src/types/function.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/types/function.rs b/src/types/function.rs index 73aa04b7..d215d6c4 100644 --- a/src/types/function.rs +++ b/src/types/function.rs @@ -42,9 +42,10 @@ impl PyCFunction { ) -> PyResult<&'a PyCFunction> { let (py, module) = py_or_module.into_py_and_maybe_module(); let doc: &'static CStr = CStr::from_bytes_with_nul(doc.as_bytes()) - .map_err(|_| PyValueError::py_err("docstring must end with NULL byte."))?; - let name = CString::new(name.as_bytes()) - .map_err(|_| PyValueError::py_err("Function name cannot contain contain NULL byte."))?; + .map_err(|_| PyValueError::new_err("docstring must end with NULL byte."))?; + let name = CString::new(name.as_bytes()).map_err(|_| { + PyValueError::new_err("Function name cannot contain contain NULL byte.") + })?; let def = match fun { PyMethodType::PyCFunction(fun) => ffi::PyMethodDef { ml_name: name.into_raw() as _, @@ -59,7 +60,7 @@ impl PyCFunction { ml_doc: doc.as_ptr() as _, }, _ => { - return Err(PyValueError::py_err( + return Err(PyValueError::new_err( "Only PyCFunction and PyCFunctionWithKeywords are valid.", )) }