@@ -17,10 +17,10 @@ use std::borrow::Cow;
1717use std:: sync:: atomic:: { AtomicBool , Ordering } ;
1818
1919use pyo3:: exceptions:: { PyImportError , PyOverflowError , PyTypeError , PyValueError } ;
20- use pyo3:: intern;
2120use pyo3:: prelude:: * ;
2221use pyo3:: sync:: GILOnceCell ;
2322use pyo3:: types:: { PyBytes , PyDict , PyString , PyType } ;
23+ use pyo3:: { intern, IntoPyObjectExt } ;
2424
2525use super :: {
2626 BYTES_16 , BYTES_32 , BYTES_8 , FALSE , FLOAT_64 , INT_16 , INT_32 , INT_64 , INT_8 , LIST_16 , LIST_32 ,
@@ -68,31 +68,31 @@ impl TypeMappings {
6868 . ok_or_else ( || {
6969 PyErr :: new :: < PyValueError , _ > ( "Type mappings are missing INT_TYPES." )
7070 } ) ?
71- . into_py ( py) ,
71+ . into_py_any ( py) ? ,
7272 float_types : locals
7373 . get_item ( "FLOAT_TYPES" ) ?
7474 . ok_or_else ( || {
7575 PyErr :: new :: < PyValueError , _ > ( "Type mappings are missing FLOAT_TYPES." )
7676 } ) ?
77- . into_py ( py) ,
77+ . into_py_any ( py) ? ,
7878 sequence_types : locals
7979 . get_item ( "SEQUENCE_TYPES" ) ?
8080 . ok_or_else ( || {
8181 PyErr :: new :: < PyValueError , _ > ( "Type mappings are missing SEQUENCE_TYPES." )
8282 } ) ?
83- . into_py ( py) ,
83+ . into_py_any ( py) ? ,
8484 mapping_types : locals
8585 . get_item ( "MAPPING_TYPES" ) ?
8686 . ok_or_else ( || {
8787 PyErr :: new :: < PyValueError , _ > ( "Type mappings are missing MAPPING_TYPES." )
8888 } ) ?
89- . into_py ( py) ,
89+ . into_py_any ( py) ? ,
9090 bytes_types : locals
9191 . get_item ( "BYTES_TYPES" ) ?
9292 . ok_or_else ( || {
9393 PyErr :: new :: < PyValueError , _ > ( "Type mappings are missing BYTES_TYPES." )
9494 } ) ?
95- . into_py ( py) ,
95+ . into_py_any ( py) ? ,
9696 } )
9797 }
9898}
@@ -103,9 +103,9 @@ static TYPE_MAPPINGS_INIT: AtomicBool = AtomicBool::new(false);
103103fn get_type_mappings ( py : Python < ' _ > ) -> PyResult < & ' static TypeMappings > {
104104 let mappings = TYPE_MAPPINGS . get_or_try_init ( py, || {
105105 fn init ( py : Python < ' _ > ) -> PyResult < TypeMappings > {
106- let locals = PyDict :: new_bound ( py) ;
107- py. run_bound (
108- "from neo4j._codec.packstream.v1.types import *" ,
106+ let locals = PyDict :: new ( py) ;
107+ py. run (
108+ c "from neo4j._codec.packstream.v1.types import *",
109109 None ,
110110 Some ( & locals) ,
111111 ) ?;
@@ -132,7 +132,7 @@ pub(super) fn pack<'py>(
132132 let type_mappings = get_type_mappings ( py) ?;
133133 let mut encoder = PackStreamEncoder :: new ( dehydration_hooks, type_mappings) ;
134134 encoder. write ( value) ?;
135- Ok ( PyBytes :: new_bound ( py, & encoder. buffer ) )
135+ Ok ( PyBytes :: new ( py, & encoder. buffer ) )
136136}
137137
138138struct PackStreamEncoder < ' a > {
@@ -176,7 +176,7 @@ impl<'a> PackStreamEncoder<'a> {
176176 return self . write_int ( value) ;
177177 }
178178
179- if value. is_instance ( & PyType :: new_bound :: < PyString > ( py) ) ? {
179+ if value. is_instance ( & PyType :: new :: < PyString > ( py) ) ? {
180180 return self . write_string ( value. extract :: < & str > ( ) ?) ;
181181 }
182182
@@ -187,14 +187,14 @@ impl<'a> PackStreamEncoder<'a> {
187187 if value. is_instance ( self . type_mappings . sequence_types . bind ( py) ) ? {
188188 let size = Self :: usize_to_u64 ( value. len ( ) ?) ?;
189189 self . write_list_header ( size) ?;
190- return value. iter ( ) ?. try_for_each ( |item| self . write ( & item?) ) ;
190+ return value. try_iter ( ) ?. try_for_each ( |item| self . write ( & item?) ) ;
191191 }
192192
193193 if value. is_instance ( self . type_mappings . mapping_types . bind ( py) ) ? {
194194 let size = Self :: usize_to_u64 ( value. getattr ( intern ! ( py, "keys" ) ) ?. call0 ( ) ?. len ( ) ?) ?;
195195 self . write_dict_header ( size) ?;
196196 let items = value. getattr ( intern ! ( py, "items" ) ) ?. call0 ( ) ?;
197- return items. iter ( ) ?. try_for_each ( |item| {
197+ return items. try_iter ( ) ?. try_for_each ( |item| {
198198 let ( key, value) = item?. extract :: < ( Bound < PyAny > , Bound < PyAny > ) > ( ) ?;
199199 let key = match key. extract :: < & str > ( ) {
200200 Ok ( key) => key,
0 commit comments