@@ -111,8 +111,8 @@ mod tests {
111111
112112 #[ test]
113113 fn test_py_to_yaml_none ( ) {
114- pyo3:: prepare_freethreaded_python ( ) ;
115- Python :: with_gil ( |py| {
114+ pyo3:: Python :: initialize ( ) ;
115+ Python :: attach ( |py| {
116116 let none = py. None ( ) . into_bound ( py) ;
117117 let val = py_to_yaml_value ( & none) . unwrap ( ) ;
118118 assert_eq ! ( val, Value :: Null ) ;
@@ -121,8 +121,8 @@ mod tests {
121121
122122 #[ test]
123123 fn test_py_to_yaml_bool ( ) {
124- pyo3:: prepare_freethreaded_python ( ) ;
125- Python :: with_gil ( |py| {
124+ pyo3:: Python :: initialize ( ) ;
125+ Python :: attach ( |py| {
126126 let t = true . into_pyobject ( py) . unwrap ( ) ;
127127 assert_eq ! ( py_to_yaml_value( t. as_any( ) ) . unwrap( ) , Value :: Bool ( true ) ) ;
128128 let f = false . into_pyobject ( py) . unwrap ( ) ;
@@ -132,8 +132,8 @@ mod tests {
132132
133133 #[ test]
134134 fn test_py_to_yaml_int ( ) {
135- pyo3:: prepare_freethreaded_python ( ) ;
136- Python :: with_gil ( |py| {
135+ pyo3:: Python :: initialize ( ) ;
136+ Python :: attach ( |py| {
137137 let i = 42i64 . into_pyobject ( py) . unwrap ( ) . into_any ( ) ;
138138 let val = py_to_yaml_value ( & i) . unwrap ( ) ;
139139 assert_eq ! ( val, Value :: Number ( 42 . into( ) ) ) ;
@@ -142,8 +142,8 @@ mod tests {
142142
143143 #[ test]
144144 fn test_py_to_yaml_large_unsigned_int ( ) {
145- pyo3:: prepare_freethreaded_python ( ) ;
146- Python :: with_gil ( |py| {
145+ pyo3:: Python :: initialize ( ) ;
146+ Python :: attach ( |py| {
147147 // i64::MAX + 1 is a valid u64 but overflows i64
148148 let large = ( i64:: MAX as u64 + 1 ) . into_pyobject ( py) . unwrap ( ) . into_any ( ) ;
149149 let val = py_to_yaml_value ( & large) . unwrap ( ) ;
@@ -156,21 +156,21 @@ mod tests {
156156
157157 #[ test]
158158 fn test_py_to_yaml_float_finite ( ) {
159- pyo3:: prepare_freethreaded_python ( ) ;
160- Python :: with_gil ( |py| {
161- let f = 3.14f64 . into_pyobject ( py) . unwrap ( ) . into_any ( ) ;
159+ pyo3:: Python :: initialize ( ) ;
160+ Python :: attach ( |py| {
161+ let f = 3.15f64 . into_pyobject ( py) . unwrap ( ) . into_any ( ) ;
162162 let val = py_to_yaml_value ( & f) . unwrap ( ) ;
163163 match val {
164- Value :: Number ( n) => assert_eq ! ( n. as_f64( ) . unwrap( ) , 3.14 ) ,
164+ Value :: Number ( n) => assert_eq ! ( n. as_f64( ) . unwrap( ) , 3.15 ) ,
165165 _ => panic ! ( "expected Number" ) ,
166166 }
167167 } ) ;
168168 }
169169
170170 #[ test]
171171 fn test_py_to_yaml_float_nan ( ) {
172- pyo3:: prepare_freethreaded_python ( ) ;
173- Python :: with_gil ( |py| {
172+ pyo3:: Python :: initialize ( ) ;
173+ Python :: attach ( |py| {
174174 let nan = f64:: NAN . into_pyobject ( py) . unwrap ( ) . into_any ( ) ;
175175 let val = py_to_yaml_value ( & nan) . unwrap ( ) ;
176176 match val {
@@ -182,8 +182,8 @@ mod tests {
182182
183183 #[ test]
184184 fn test_py_to_yaml_float_inf ( ) {
185- pyo3:: prepare_freethreaded_python ( ) ;
186- Python :: with_gil ( |py| {
185+ pyo3:: Python :: initialize ( ) ;
186+ Python :: attach ( |py| {
187187 let inf = f64:: INFINITY . into_pyobject ( py) . unwrap ( ) . into_any ( ) ;
188188 let val = py_to_yaml_value ( & inf) . unwrap ( ) ;
189189 match val {
@@ -195,8 +195,8 @@ mod tests {
195195
196196 #[ test]
197197 fn test_py_to_yaml_float_neg_inf ( ) {
198- pyo3:: prepare_freethreaded_python ( ) ;
199- Python :: with_gil ( |py| {
198+ pyo3:: Python :: initialize ( ) ;
199+ Python :: attach ( |py| {
200200 let neg_inf = f64:: NEG_INFINITY . into_pyobject ( py) . unwrap ( ) . into_any ( ) ;
201201 let val = py_to_yaml_value ( & neg_inf) . unwrap ( ) ;
202202 match val {
@@ -211,18 +211,18 @@ mod tests {
211211
212212 #[ test]
213213 fn test_py_to_yaml_string ( ) {
214- pyo3:: prepare_freethreaded_python ( ) ;
215- Python :: with_gil ( |py| {
214+ pyo3:: Python :: initialize ( ) ;
215+ Python :: attach ( |py| {
216216 let s = "hello" . into_pyobject ( py) . unwrap ( ) . into_any ( ) ;
217217 assert_eq ! ( py_to_yaml_value( & s) . unwrap( ) , Value :: String ( "hello" . into( ) ) ) ;
218218 } ) ;
219219 }
220220
221221 #[ test]
222222 fn test_py_to_yaml_list ( ) {
223- pyo3:: prepare_freethreaded_python ( ) ;
224- Python :: with_gil ( |py| {
225- let list = PyList :: new ( py, & [ 1i64 , 2 , 3 ] ) . unwrap ( ) ;
223+ pyo3:: Python :: initialize ( ) ;
224+ Python :: attach ( |py| {
225+ let list = PyList :: new ( py, [ 1i64 , 2 , 3 ] ) . unwrap ( ) ;
226226 let val = py_to_yaml_value ( list. as_any ( ) ) . unwrap ( ) ;
227227 assert_eq ! (
228228 val,
@@ -237,8 +237,8 @@ mod tests {
237237
238238 #[ test]
239239 fn test_py_to_yaml_dict ( ) {
240- pyo3:: prepare_freethreaded_python ( ) ;
241- Python :: with_gil ( |py| {
240+ pyo3:: Python :: initialize ( ) ;
241+ Python :: attach ( |py| {
242242 let dict = PyDict :: new ( py) ;
243243 dict. set_item ( "key" , "value" ) . unwrap ( ) ;
244244 let val = py_to_yaml_value ( dict. as_any ( ) ) . unwrap ( ) ;
@@ -250,53 +250,53 @@ mod tests {
250250
251251 #[ test]
252252 fn test_py_to_yaml_unsupported_type_rejected ( ) {
253- pyo3:: prepare_freethreaded_python ( ) ;
254- Python :: with_gil ( |py| {
253+ pyo3:: Python :: initialize ( ) ;
254+ Python :: attach ( |py| {
255255 let set = py. eval ( pyo3:: ffi:: c_str!( "set()" ) , None , None ) . unwrap ( ) ;
256256 assert ! ( py_to_yaml_value( & set) . is_err( ) ) ;
257257 } ) ;
258258 }
259259
260260 #[ test]
261261 fn test_yaml_to_py_null ( ) {
262- pyo3:: prepare_freethreaded_python ( ) ;
263- Python :: with_gil ( |py| {
262+ pyo3:: Python :: initialize ( ) ;
263+ Python :: attach ( |py| {
264264 let obj = yaml_value_to_py ( py, & Value :: Null ) . unwrap ( ) ;
265265 assert ! ( obj. bind( py) . is_none( ) ) ;
266266 } ) ;
267267 }
268268
269269 #[ test]
270270 fn test_yaml_to_py_bool ( ) {
271- pyo3:: prepare_freethreaded_python ( ) ;
272- Python :: with_gil ( |py| {
271+ pyo3:: Python :: initialize ( ) ;
272+ Python :: attach ( |py| {
273273 let obj = yaml_value_to_py ( py, & Value :: Bool ( true ) ) . unwrap ( ) ;
274274 assert ! ( obj. extract:: <bool >( py) . unwrap( ) ) ;
275275 } ) ;
276276 }
277277
278278 #[ test]
279279 fn test_yaml_to_py_number_i64 ( ) {
280- pyo3:: prepare_freethreaded_python ( ) ;
281- Python :: with_gil ( |py| {
280+ pyo3:: Python :: initialize ( ) ;
281+ Python :: attach ( |py| {
282282 let obj = yaml_value_to_py ( py, & Value :: Number ( 42 . into ( ) ) ) . unwrap ( ) ;
283283 assert_eq ! ( obj. extract:: <i64 >( py) . unwrap( ) , 42 ) ;
284284 } ) ;
285285 }
286286
287287 #[ test]
288288 fn test_yaml_to_py_string ( ) {
289- pyo3:: prepare_freethreaded_python ( ) ;
290- Python :: with_gil ( |py| {
289+ pyo3:: Python :: initialize ( ) ;
290+ Python :: attach ( |py| {
291291 let obj = yaml_value_to_py ( py, & Value :: String ( "hello" . into ( ) ) ) . unwrap ( ) ;
292292 assert_eq ! ( obj. extract:: <String >( py) . unwrap( ) , "hello" ) ;
293293 } ) ;
294294 }
295295
296296 #[ test]
297297 fn test_yaml_to_py_sequence ( ) {
298- pyo3:: prepare_freethreaded_python ( ) ;
299- Python :: with_gil ( |py| {
298+ pyo3:: Python :: initialize ( ) ;
299+ Python :: attach ( |py| {
300300 let seq = Value :: Sequence ( vec ! [ Value :: Number ( 1 . into( ) ) , Value :: Number ( 2 . into( ) ) ] ) ;
301301 let obj = yaml_value_to_py ( py, & seq) . unwrap ( ) ;
302302 let list = obj. extract :: < Vec < i64 > > ( py) . unwrap ( ) ;
@@ -306,8 +306,8 @@ mod tests {
306306
307307 #[ test]
308308 fn test_yaml_to_py_tagged_strips_tag ( ) {
309- pyo3:: prepare_freethreaded_python ( ) ;
310- Python :: with_gil ( |py| {
309+ pyo3:: Python :: initialize ( ) ;
310+ Python :: attach ( |py| {
311311 let tagged = Value :: Tagged ( Box :: new ( serde_yaml:: value:: TaggedValue {
312312 tag : serde_yaml:: value:: Tag :: new ( "!custom" ) ,
313313 value : Value :: String ( "inner" . into ( ) ) ,
0 commit comments