Skip to content

Commit 5db7ba6

Browse files
committed
Update to pyo3 0.5.0 alpha2
1 parent 2a662f5 commit 5db7ba6

File tree

8 files changed

+16
-13
lines changed

8 files changed

+16
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ libc = "0.2"
1515
num-complex = "0.2"
1616
num-traits = "0.2.6"
1717
ndarray = "0.12"
18-
pyo3 = "0.4.1"
18+
pyo3 = "0.5.0-alpha.2"

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@ Example
3838
name = "numpy-test"
3939

4040
[dependencies]
41-
pyo3 = "^0.4.1"
41+
pyo3 = "^0.5.0-alpha.2"
4242
numpy = "0.3"
4343
```
4444

4545
``` rust
4646
extern crate numpy;
4747
extern crate pyo3;
4848
use numpy::{PyArray1, get_array_module};
49-
use pyo3::prelude::{ObjectProtocol, PyDict, PyResult, Python};
49+
use pyo3::prelude::{ObjectProtocol, PyResult, Python};
50+
use pyo3::types::PyDict;
5051

5152
fn main() -> Result<(), ()> {
5253
let gil = Python::acquire_gil();
@@ -85,7 +86,7 @@ numpy = "0.3"
8586
ndarray = "0.12"
8687

8788
[dependencies.pyo3]
88-
version = "^0.4.1"
89+
version = "^0.5.0-alpha.2"
8990
features = ["extension-module"]
9091
```
9192

example/extensions/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ numpy = { path = "../.." }
1212
ndarray = "0.12"
1313

1414
[dependencies.pyo3]
15-
version = "0.4.1"
15+
version = "0.5.0-alpha.2"
1616
features = ["extension-module"]

src/array.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
use ndarray::*;
33
use npyffi::{self, npy_intp, NPY_ORDER, PY_ARRAY_API};
44
use num_traits::AsPrimitive;
5-
use pyo3::*;
5+
use pyo3::{exceptions::TypeError, ffi, prelude::*, types::PyObjectRef};
6+
use pyo3::{PyDowncastError, PyObjectWithToken, ToPyPointer};
67
use std::iter::ExactSizeIterator;
78
use std::marker::PhantomData;
89
use std::mem;
@@ -123,7 +124,7 @@ impl<'a, T: TypeNum, D: Dimension> FromPyObject<'a> for &'a PyArray<T, D> {
123124
if let Some(ndim) = D::NDIM {
124125
let ptr = ob.as_ptr() as *mut npyffi::PyArrayObject;
125126
if (*ptr).nd as usize != ndim {
126-
return Err(PyErr::new::<exc::TypeError, _>(format!(
127+
return Err(PyErr::new::<TypeError, _>(format!(
127128
"specified dim was {}, but actual dim was {}",
128129
ndim,
129130
(*ptr).nd

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use array::PyArray;
44
use convert::ToNpyDims;
5-
use pyo3::*;
5+
use pyo3::{exceptions as exc, PyErr, PyResult};
66
use std::error;
77
use std::fmt;
88
use types::{NpyDataType, TypeNum};

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ extern crate libc;
3838
extern crate ndarray;
3939
extern crate num_complex;
4040
extern crate num_traits;
41+
#[macro_use]
4142
extern crate pyo3;
4243

4344
pub mod array;

src/slice_box.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::types::TypeNum;
2-
use pyo3::{self, ffi, typeob, PyObjectAlloc, Python, ToPyPointer};
2+
use pyo3::{ffi, typeob, types::PyObjectRef, PyObjectAlloc, Python, ToPyPointer};
33
use std::os::raw::c_void;
44

55
#[repr(C)]
@@ -26,7 +26,7 @@ impl<T> SliceBox<T> {
2626

2727
impl<T> typeob::PyTypeInfo for SliceBox<T> {
2828
type Type = ();
29-
type BaseType = pyo3::PyObjectRef;
29+
type BaseType = PyObjectRef;
3030
const NAME: &'static str = "SliceBox";
3131
const DESCRIPTION: &'static str = "Memory store for PyArray made by IntoPyArray.";
3232
const FLAGS: usize = 0;
@@ -39,7 +39,7 @@ impl<T> typeob::PyTypeInfo for SliceBox<T> {
3939
}
4040
}
4141

42-
impl<T: TypeNum> typeob::PyTypeObject for SliceBox<T> {
42+
impl<T: TypeNum> typeob::PyTypeCreate for SliceBox<T> {
4343
#[inline(always)]
4444
fn init_type() {
4545
static START: std::sync::Once = std::sync::ONCE_INIT;

tests/array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ extern crate pyo3;
44

55
use ndarray::*;
66
use numpy::*;
7-
use pyo3::prelude::*;
7+
use pyo3::{prelude::*, types::PyDict, types::PyList};
88

99
#[test]
1010
fn new_c_order() {
@@ -124,7 +124,7 @@ fn is_instance() {
124124
let py = gil.python();
125125
let arr = PyArray2::<f64>::new(gil.python(), [3, 5], false);
126126
assert!(py.is_instance::<PyArray2<f64>, _>(arr).unwrap());
127-
assert!(!py.is_instance::<pyo3::PyList, _>(arr).unwrap());
127+
assert!(!py.is_instance::<PyList, _>(arr).unwrap());
128128
}
129129

130130
#[test]

0 commit comments

Comments
 (0)