@@ -38,12 +38,14 @@ fn impl_into_py_enum(ast: &DeriveInput, e: &DataEnum) -> TokenStream {
3838 let kwargs_toks = fields_to_kwargs ( & var. fields , true ) ;
3939 toks. push ( quote ! {
4040 Self :: #varname { #( #fieldnames, ) * .. } => {
41- let libcst = pyo3:: types:: PyModule :: import( py, "libcst" ) ?;
41+ use pyo3:: types:: PyAnyMethods ;
42+
43+ let libcst = pyo3:: types:: PyModule :: import_bound( py, "libcst" ) ?;
4244 let kwargs = #kwargs_toks ;
4345 Ok ( libcst
4446 . getattr( stringify!( #varname) )
4547 . expect( stringify!( no #varname found in libcst) )
46- . call( ( ) , Some ( kwargs) ) ?
48+ . call( ( ) , Some ( & kwargs) ) ?
4749 . into( ) )
4850 }
4951 } )
@@ -87,12 +89,13 @@ fn impl_into_py_struct(ast: &DeriveInput, e: &DataStruct) -> TokenStream {
8789 #[ automatically_derived]
8890 impl #generics crate :: nodes:: traits:: py:: TryIntoPy <pyo3:: PyObject > for #ident #generics {
8991 fn try_into_py( self , py: pyo3:: Python ) -> pyo3:: PyResult <pyo3:: PyObject > {
90- let libcst = pyo3:: types:: PyModule :: import( py, "libcst" ) ?;
92+ use pyo3:: types:: PyAnyMethods ;
93+ let libcst = pyo3:: types:: PyModule :: import_bound( py, "libcst" ) ?;
9194 let kwargs = #kwargs_toks ;
9295 Ok ( libcst
9396 . getattr( stringify!( #ident) )
9497 . expect( stringify!( no #ident found in libcst) )
95- . call( ( ) , Some ( kwargs) ) ?
98+ . call( ( ) , Some ( & kwargs) ) ?
9699 . into( ) )
97100 }
98101 }
@@ -162,15 +165,15 @@ fn fields_to_kwargs(fields: &Fields, is_enum: bool) -> quote::__private::TokenSt
162165 #( #optional_rust_varnames. map( |x| x. try_into_py( py) ) . transpose( ) ?. map( |x| ( stringify!( #optional_py_varnames) , x) ) , ) *
163166 } ;
164167 if empty_kwargs {
165- quote ! { pyo3:: types:: PyDict :: new ( py) }
168+ quote ! { pyo3:: types:: PyDict :: new_bound ( py) }
166169 } else {
167170 quote ! {
168171 [ #kwargs_pairs #optional_pairs ]
169172 . iter( )
170173 . filter( |x| x. is_some( ) )
171174 . map( |x| x. as_ref( ) . unwrap( ) )
172175 . collect:: <Vec <_>>( )
173- . into_py_dict ( py)
176+ . into_py_dict_bound ( py)
174177 }
175178 }
176179}
0 commit comments