1
- use crate :: instance:: Py2 ;
1
+ use crate :: instance:: Bound ;
2
2
use crate :: panic:: PanicException ;
3
3
use crate :: type_object:: PyTypeInfo ;
4
4
use crate :: types:: any:: PyAnyMethods ;
@@ -65,16 +65,16 @@ impl<'a> PyDowncastError<'a> {
65
65
66
66
/// Error that indicates a failure to convert a PyAny to a more specific Python type.
67
67
#[ derive( Debug ) ]
68
- pub ( crate ) struct PyDowncastError2 < ' a , ' py > {
69
- from : & ' a Py2 < ' py , PyAny > ,
68
+ pub struct DowncastError < ' a , ' py > {
69
+ from : & ' a Bound < ' py , PyAny > ,
70
70
to : Cow < ' static , str > ,
71
71
}
72
72
73
- impl < ' a , ' py > PyDowncastError2 < ' a , ' py > {
73
+ impl < ' a , ' py > DowncastError < ' a , ' py > {
74
74
/// Create a new `PyDowncastError` representing a failure to convert the object
75
75
/// `from` into the type named in `to`.
76
- pub fn new ( from : & ' a Py2 < ' py , PyAny > , to : impl Into < Cow < ' static , str > > ) -> Self {
77
- PyDowncastError2 {
76
+ pub fn new ( from : & ' a Bound < ' py , PyAny > , to : impl Into < Cow < ' static , str > > ) -> Self {
77
+ DowncastError {
78
78
from,
79
79
to : to. into ( ) ,
80
80
}
@@ -83,16 +83,16 @@ impl<'a, 'py> PyDowncastError2<'a, 'py> {
83
83
84
84
/// Error that indicates a failure to convert a PyAny to a more specific Python type.
85
85
#[ derive( Debug ) ]
86
- pub ( crate ) struct PyDowncastIntoError < ' py > {
87
- from : Py2 < ' py , PyAny > ,
86
+ pub struct DowncastIntoError < ' py > {
87
+ from : Bound < ' py , PyAny > ,
88
88
to : Cow < ' static , str > ,
89
89
}
90
90
91
- impl < ' py > PyDowncastIntoError < ' py > {
92
- /// Create a new `PyDowncastIntoError ` representing a failure to convert the object
91
+ impl < ' py > DowncastIntoError < ' py > {
92
+ /// Create a new `DowncastIntoError ` representing a failure to convert the object
93
93
/// `from` into the type named in `to`.
94
- pub fn new ( from : Py2 < ' py , PyAny > , to : impl Into < Cow < ' static , str > > ) -> Self {
95
- PyDowncastIntoError {
94
+ pub fn new ( from : Bound < ' py , PyAny > , to : impl Into < Cow < ' static , str > > ) -> Self {
95
+ DowncastIntoError {
96
96
from,
97
97
to : to. into ( ) ,
98
98
}
@@ -811,13 +811,13 @@ impl<'a> std::error::Error for PyDowncastError<'a> {}
811
811
812
812
impl < ' a > std:: fmt:: Display for PyDowncastError < ' a > {
813
813
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> Result < ( ) , std:: fmt:: Error > {
814
- display_downcast_error ( f, Py2 :: borrowed_from_gil_ref ( & self . from ) , & self . to )
814
+ display_downcast_error ( f, Bound :: borrowed_from_gil_ref ( & self . from ) , & self . to )
815
815
}
816
816
}
817
817
818
- /// Convert `PyDowncastError2 ` to Python `TypeError`.
819
- impl std:: convert:: From < PyDowncastError2 < ' _ , ' _ > > for PyErr {
820
- fn from ( err : PyDowncastError2 < ' _ , ' _ > ) -> PyErr {
818
+ /// Convert `DowncastError ` to Python `TypeError`.
819
+ impl std:: convert:: From < DowncastError < ' _ , ' _ > > for PyErr {
820
+ fn from ( err : DowncastError < ' _ , ' _ > ) -> PyErr {
821
821
let args = PyDowncastErrorArguments {
822
822
from : err. from . get_type ( ) . into ( ) ,
823
823
to : err. to ,
@@ -827,17 +827,17 @@ impl std::convert::From<PyDowncastError2<'_, '_>> for PyErr {
827
827
}
828
828
}
829
829
830
- impl std:: error:: Error for PyDowncastError2 < ' _ , ' _ > { }
830
+ impl std:: error:: Error for DowncastError < ' _ , ' _ > { }
831
831
832
- impl std:: fmt:: Display for PyDowncastError2 < ' _ , ' _ > {
832
+ impl std:: fmt:: Display for DowncastError < ' _ , ' _ > {
833
833
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> Result < ( ) , std:: fmt:: Error > {
834
834
display_downcast_error ( f, self . from , & self . to )
835
835
}
836
836
}
837
837
838
- /// Convert `PyDowncastIntoError ` to Python `TypeError`.
839
- impl std:: convert:: From < PyDowncastIntoError < ' _ > > for PyErr {
840
- fn from ( err : PyDowncastIntoError < ' _ > ) -> PyErr {
838
+ /// Convert `DowncastIntoError ` to Python `TypeError`.
839
+ impl std:: convert:: From < DowncastIntoError < ' _ > > for PyErr {
840
+ fn from ( err : DowncastIntoError < ' _ > ) -> PyErr {
841
841
let args = PyDowncastErrorArguments {
842
842
from : err. from . get_type ( ) . into ( ) ,
843
843
to : err. to ,
@@ -847,17 +847,17 @@ impl std::convert::From<PyDowncastIntoError<'_>> for PyErr {
847
847
}
848
848
}
849
849
850
- impl std:: error:: Error for PyDowncastIntoError < ' _ > { }
850
+ impl std:: error:: Error for DowncastIntoError < ' _ > { }
851
851
852
- impl std:: fmt:: Display for PyDowncastIntoError < ' _ > {
852
+ impl std:: fmt:: Display for DowncastIntoError < ' _ > {
853
853
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> Result < ( ) , std:: fmt:: Error > {
854
854
display_downcast_error ( f, & self . from , & self . to )
855
855
}
856
856
}
857
857
858
858
fn display_downcast_error (
859
859
f : & mut std:: fmt:: Formatter < ' _ > ,
860
- from : & Py2 < ' _ , PyAny > ,
860
+ from : & Bound < ' _ , PyAny > ,
861
861
to : & str ,
862
862
) -> std:: fmt:: Result {
863
863
write ! (
0 commit comments