Skip to content

Commit

Permalink
Merge pull request #1171 from davidhewitt/fix-new-err
Browse files Browse the repository at this point in the history
Fix build for new apis
  • Loading branch information
davidhewitt committed Sep 10, 2020
2 parents 151af7a + c519b4d commit 1489ca2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/types/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _,
Expand All @@ -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.",
))
}
Expand Down

0 comments on commit 1489ca2

Please sign in to comment.