3
3
use std:: error:: Error ;
4
4
use std:: fmt;
5
5
6
- use pyo3:: { exceptions:: PyTypeError , Py , PyErr , PyErrArguments , PyObject , Python , ToPyObject } ;
6
+ use pyo3:: {
7
+ exceptions:: PyTypeError , Bound , Py , PyErr , PyErrArguments , PyObject , Python , ToPyObject ,
8
+ } ;
7
9
8
10
use crate :: dtype:: PyArrayDescr ;
9
11
@@ -59,13 +61,13 @@ impl_pyerr!(DimensionalityError);
59
61
60
62
/// Represents that types of the given arrays do not match.
61
63
#[ derive( Debug ) ]
62
- pub struct TypeError < ' a > {
63
- from : & ' a PyArrayDescr ,
64
- to : & ' a PyArrayDescr ,
64
+ pub struct TypeError < ' py > {
65
+ from : Bound < ' py , PyArrayDescr > ,
66
+ to : Bound < ' py , PyArrayDescr > ,
65
67
}
66
68
67
- impl < ' a > TypeError < ' a > {
68
- pub ( crate ) fn new ( from : & ' a PyArrayDescr , to : & ' a PyArrayDescr ) -> Self {
69
+ impl < ' py > TypeError < ' py > {
70
+ pub ( crate ) fn new ( from : Bound < ' py , PyArrayDescr > , to : Bound < ' py , PyArrayDescr > ) -> Self {
69
71
Self { from, to }
70
72
}
71
73
}
@@ -86,8 +88,8 @@ struct TypeErrorArguments {
86
88
impl PyErrArguments for TypeErrorArguments {
87
89
fn arguments < ' py > ( self , py : Python < ' py > ) -> PyObject {
88
90
let err = TypeError {
89
- from : self . from . as_ref ( py) ,
90
- to : self . to . as_ref ( py) ,
91
+ from : self . from . into_bound ( py) ,
92
+ to : self . to . into_bound ( py) ,
91
93
} ;
92
94
93
95
err. to_string ( ) . to_object ( py)
0 commit comments