@@ -14,7 +14,7 @@ use openssl::x509::{X509Ref, X509};
1414use pyo3:: create_exception;
1515use pyo3:: exceptions:: PyException ;
1616use pyo3:: prelude:: * ;
17- use pyo3:: types:: PyBytes ;
17+ use pyo3:: types:: { PyBytes , PyModule } ;
1818use pyo3:: wrap_pymodule;
1919
2020fn _sign (
@@ -108,7 +108,7 @@ fn material_from_sources(
108108 std:: fs:: read ( path) . map_err ( |err| CertificateError :: new_err ( err. to_string ( ) ) )
109109 }
110110 ( None , Some ( obj) ) => {
111- let obj = obj. as_ref ( py) ;
111+ let obj = obj. bind ( py) ;
112112
113113 if let Ok ( value) = obj. extract :: < & str > ( ) {
114114 Ok ( value. as_bytes ( ) . to_vec ( ) )
@@ -130,7 +130,7 @@ fn material_from_sources(
130130}
131131
132132#[ pymodule]
133- fn exceptions ( py : Python , m : & PyModule ) -> PyResult < ( ) > {
133+ fn exceptions ( py : Python < ' _ > , m : & Bound < ' _ , PyModule > ) -> PyResult < ( ) > {
134134 m. add ( "RsmimeError" , py. get_type :: < RsmimeError > ( ) ) ?;
135135 m. add ( "CertificateError" , py. get_type :: < CertificateError > ( ) ) ?;
136136 m. add (
@@ -143,14 +143,16 @@ fn exceptions(py: Python, m: &PyModule) -> PyResult<()> {
143143}
144144
145145#[ pymodule]
146- fn rsmime ( py : Python , m : & PyModule ) -> PyResult < ( ) > {
146+ fn rsmime ( py : Python < ' _ > , m : & Bound < ' _ , PyModule > ) -> PyResult < ( ) > {
147147 let exceptions = wrap_pymodule ! ( exceptions) ;
148148
149149 py. import ( "sys" ) ?
150150 . getattr ( "modules" ) ?
151151 . set_item ( "rsmime.exceptions" , exceptions ( py) ) ?;
152152
153- m. add_wrapped ( exceptions) ?;
153+ let exc_py = exceptions ( py) ;
154+ let exc_bound = exc_py. bind ( py) ;
155+ m. add_submodule ( & exc_bound) ?;
154156 m. add_class :: < Rsmime > ( ) ?;
155157
156158 Ok ( ( ) )
@@ -191,15 +193,15 @@ impl Rsmime {
191193
192194 #[ staticmethod]
193195 #[ pyo3( signature = ( message, * , raise_on_expired = false ) ) ]
194- fn verify ( py_ : Python < ' _ > , message : Vec < u8 > , raise_on_expired : bool ) -> PyResult < PyObject > {
196+ fn verify ( py_ : Python < ' _ > , message : Vec < u8 > , raise_on_expired : bool ) -> PyResult < Py < PyAny > > {
195197 match _verify ( & message, raise_on_expired) {
196198 Ok ( data) => Ok ( PyBytes :: new ( py_, & data) . into ( ) ) ,
197199 Err ( err) => Err ( err) ,
198200 }
199201 }
200202
201203 #[ pyo3( signature = ( message, * , detached = false ) ) ]
202- fn sign ( self_ : PyRef < ' _ , Self > , message : Vec < u8 > , detached : bool ) -> PyResult < PyObject > {
204+ fn sign ( self_ : PyRef < ' _ , Self > , message : Vec < u8 > , detached : bool ) -> PyResult < Py < PyAny > > {
203205 match _sign (
204206 self_. stack . as_ref ( ) ,
205207 self_. cert . as_ref ( ) ,
0 commit comments