Skip to content

Commit 53f7499

Browse files
messenseadamreichold
authored andcommitted
Upgrade pyo3 to 0.20
1 parent 1671b00 commit 53f7499

File tree

10 files changed

+15
-12
lines changed

10 files changed

+15
-12
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ num-complex = ">= 0.2, < 0.5"
2222
num-integer = "0.1"
2323
num-traits = "0.2"
2424
ndarray = ">= 0.13, < 0.16"
25-
pyo3 = { version = "0.19", default-features = false, features = ["macros"] }
25+
pyo3 = { version = "0.20", default-features = false, features = ["macros"] }
2626
rustc-hash = "1.1"
2727

2828
[dev-dependencies]
29-
pyo3 = { version = "0.19", default-features = false, features = ["auto-initialize"] }
29+
pyo3 = { version = "0.20", default-features = false, features = ["auto-initialize"] }
3030
nalgebra = { version = "0.32", default-features = false, features = ["std"] }
3131

3232
[package.metadata.docs.rs]

examples/linalg/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "rust_linalg"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12-
pyo3 = { version = "0.19", features = ["extension-module"] }
12+
pyo3 = { version = "0.20", features = ["extension-module"] }
1313
numpy = { path = "../.." }
1414
ndarray-linalg = { version = "0.14.1", features = ["openblas-system"] }
1515

examples/linalg/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build-system]
22
build-backend = "maturin"
3-
requires = ["maturin>=0.13,<0.14"]
3+
requires = ["maturin>=1.0,<2.0"]

examples/parallel/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "rust_parallel"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12-
pyo3 = { version = "0.19", features = ["extension-module", "multiple-pymethods"] }
12+
pyo3 = { version = "0.20", features = ["extension-module", "multiple-pymethods"] }
1313
numpy = { path = "../.." }
1414
ndarray = { version = "0.15", features = ["rayon", "blas"] }
1515
blas-src = { version = "0.8", features = ["openblas"] }

examples/parallel/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build-system]
22
build-backend = "maturin"
3-
requires = ["maturin>=0.13,<0.14"]
3+
requires = ["maturin>=1.0,<2.0"]

examples/simple/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "rust_ext"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12-
pyo3 = { version = "0.19", features = ["extension-module", "abi3-py37"] }
12+
pyo3 = { version = "0.20", features = ["extension-module", "abi3-py37"] }
1313
numpy = { path = "../.." }
1414

1515
[workspace]

examples/simple/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build-system]
22
build-backend = "maturin"
3-
requires = ["maturin>=0.13,<0.14"]
3+
requires = ["maturin>=1.0,<2.0"]

examples/simple/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ fn rust_ext<'py>(_py: Python<'py>, m: &'py PyModule) -> PyResult<()> {
9191
let x = d
9292
.get_item("x")
9393
.unwrap()
94+
.unwrap()
9495
.downcast::<PyArray1<f64>>()
9596
.unwrap();
9697

src/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl<T, D> Deref for PyArray<T, D> {
155155
}
156156
}
157157

158-
impl<T, D> AsPyPointer for PyArray<T, D> {
158+
unsafe impl<T, D> AsPyPointer for PyArray<T, D> {
159159
#[inline]
160160
fn as_ptr(&self) -> *mut ffi::PyObject {
161161
self.0.as_ptr()

src/dtype.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use pyo3::{
1212
ffi::{self, PyTuple_Size},
1313
pyobject_native_type_extract, pyobject_native_type_named,
1414
types::{PyDict, PyTuple, PyType},
15-
AsPyPointer, FromPyObject, FromPyPointer, IntoPyPointer, PyAny, PyNativeType, PyObject,
16-
PyResult, PyTypeInfo, Python, ToPyObject,
15+
AsPyPointer, FromPyObject, FromPyPointer, PyAny, PyNativeType, PyObject, PyResult, PyTypeInfo,
16+
Python, ToPyObject,
1717
};
1818
#[cfg(feature = "half")]
1919
use pyo3::{sync::GILOnceCell, IntoPy, Py};
@@ -352,7 +352,7 @@ impl PyArrayDescr {
352352
let dict = unsafe { PyDict::from_borrowed_ptr(self.py(), (*self.as_dtype_ptr()).fields) };
353353
// NumPy guarantees that fields are tuples of proper size and type, so this should never panic.
354354
let tuple = dict
355-
.get_item(name)
355+
.get_item(name)?
356356
.ok_or_else(|| PyIndexError::new_err(name.to_owned()))?
357357
.downcast::<PyTuple>()
358358
.unwrap();
@@ -609,6 +609,7 @@ mod tests {
609609
let dt = locals
610610
.get_item("dtype")
611611
.unwrap()
612+
.unwrap()
612613
.downcast::<PyArrayDescr>()
613614
.unwrap();
614615

@@ -644,6 +645,7 @@ mod tests {
644645
let dt = locals
645646
.get_item("dtype")
646647
.unwrap()
648+
.unwrap()
647649
.downcast::<PyArrayDescr>()
648650
.unwrap();
649651

0 commit comments

Comments
 (0)