Skip to content

Commit

Permalink
Upgrade pyo3 to 0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Oct 25, 2021
1 parent 0ffe035 commit 5640877
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ libc = "0.2"
num-complex = ">= 0.2, <= 0.4"
num-traits = "0.2"
ndarray = ">= 0.13, < 0.16"
pyo3 = { version = "0.14", default-features = false }
pyo3 = { git = "https://github.com/PyO3/pyo3.git", branch = "release-0.15", default-features = false }

[dev-dependencies]
pyo3 = { version = "0.14", features = ["auto-initialize"] }
pyo3 = { git = "https://github.com/PyO3/pyo3.git", branch = "release-0.15", features = ["auto-initialize"] }

[features]
# In default setting, python version is automatically detected
Expand Down
8 changes: 4 additions & 4 deletions src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ impl<T: Element> PyArray<T, Ix1> {
)
};
if res.is_null() {
Err(PyErr::fetch(self.py()))
Err(PyErr::fetch(self.py()).expect("error return without exception set"))
} else {
Ok(())
}
Expand Down Expand Up @@ -959,7 +959,7 @@ impl<T: Element, D> PyArray<T, D> {
let other_ptr = other.as_array_ptr();
let result = unsafe { PY_ARRAY_API.PyArray_CopyInto(other_ptr, self_ptr) };
if result == -1 {
Err(PyErr::fetch(self.py()))
Err(PyErr::fetch(self.py()).expect("error return without exception set"))
} else {
Ok(())
}
Expand All @@ -986,7 +986,7 @@ impl<T: Element, D> PyArray<T, D> {
)
};
if ptr.is_null() {
Err(PyErr::fetch(self.py()))
Err(PyErr::fetch(self.py()).expect("error return without exception set"))
} else {
Ok(unsafe { PyArray::<U, D>::from_owned_ptr(self.py(), ptr) })
}
Expand Down Expand Up @@ -1039,7 +1039,7 @@ impl<T: Element, D> PyArray<T, D> {
)
};
if ptr.is_null() {
Err(PyErr::fetch(self.py()))
Err(PyErr::fetch(self.py()).expect("error return without exception set"))
} else {
Ok(unsafe { PyArray::<T, D2>::from_owned_ptr(self.py(), ptr) })
}
Expand Down
12 changes: 6 additions & 6 deletions src/npyiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,22 +279,22 @@ impl<'py, T, I> NpySingleIter<'py, T, I> {
let mut iterator = match ptr::NonNull::new(iterator) {
Some(iter) => iter,
None => {
return Err(PyErr::fetch(py));
return Err(PyErr::fetch(py).expect("error return without exception set"));
}
};

let iternext =
match unsafe { PY_ARRAY_API.NpyIter_GetIterNext(iterator.as_mut(), ptr::null_mut()) } {
Some(ptr) => ptr,
None => {
return Err(PyErr::fetch(py));
return Err(PyErr::fetch(py).expect("error return without exception set"));
}
};
let dataptr = unsafe { PY_ARRAY_API.NpyIter_GetDataPtrArray(iterator.as_mut()) };

if dataptr.is_null() {
unsafe { PY_ARRAY_API.NpyIter_Deallocate(iterator.as_mut()) };
return Err(PyErr::fetch(py));
return Err(PyErr::fetch(py).expect("error return without exception set"));
}

let iter_size = unsafe { PY_ARRAY_API.NpyIter_GetIterSize(iterator.as_mut()) };
Expand Down Expand Up @@ -512,22 +512,22 @@ impl<'py, T, S: MultiIterModeWithManyArrays> NpyMultiIter<'py, T, S> {
let mut iterator = match ptr::NonNull::new(iterator) {
Some(ptr) => ptr,
None => {
return Err(PyErr::fetch(py));
return Err(PyErr::fetch(py).expect("error return without exception set"));
}
};

let iternext =
match unsafe { PY_ARRAY_API.NpyIter_GetIterNext(iterator.as_mut(), ptr::null_mut()) } {
Some(ptr) => ptr,
None => {
return Err(PyErr::fetch(py));
return Err(PyErr::fetch(py).expect("error return without exception set"));
}
};
let dataptr = unsafe { PY_ARRAY_API.NpyIter_GetDataPtrArray(iterator.as_mut()) };

if dataptr.is_null() {
unsafe { PY_ARRAY_API.NpyIter_Deallocate(iterator.as_mut()) };
return Err(PyErr::fetch(py));
return Err(PyErr::fetch(py).expect("error return without exception set"));
}

let iter_size = unsafe { PY_ARRAY_API.NpyIter_GetIterSize(iterator.as_mut()) };
Expand Down

0 comments on commit 5640877

Please sign in to comment.