3
3
//! Python Sequence Interface
4
4
//! Trait and support implementation for implementing sequence
5
5
6
+ use crate :: conversion:: { FromPyObject , IntoPy } ;
6
7
use crate :: err:: { PyErr , PyResult } ;
8
+ use crate :: gil:: GILPool ;
7
9
use crate :: objectprotocol:: ObjectProtocol ;
8
10
use crate :: types:: PyAny ;
9
- use crate :: { exceptions , ffi , FromPyObject , IntoPy , PyClass , PyObject } ;
11
+ use crate :: { callback , catch_unwind , exceptions , ffi , PyCell , PyClass , PyObject , Python } ;
10
12
use std:: os:: raw:: c_int;
11
13
12
14
/// Sequence interface
@@ -255,10 +257,10 @@ mod sq_ass_item_impl {
255
257
where
256
258
T : for < ' p > PySequenceSetItemProtocol < ' p > ,
257
259
{
258
- let py = crate :: Python :: assume_gil_acquired ( ) ;
259
- crate :: catch_unwind!( py, {
260
- let _pool = crate :: GILPool :: new( py) ;
261
- let slf = py. from_borrowed_ptr:: <crate :: PyCell <T >>( slf) ;
260
+ let py = Python :: assume_gil_acquired ( ) ;
261
+ catch_unwind ! ( py, {
262
+ let _pool = GILPool :: new( py) ;
263
+ let slf = py. from_borrowed_ptr:: <PyCell <T >>( slf) ;
262
264
263
265
if value. is_null( ) {
264
266
return Err ( PyErr :: new:: <exceptions:: NotImplementedError , _>( format!(
@@ -271,7 +273,7 @@ mod sq_ass_item_impl {
271
273
let value = py. from_borrowed_ptr:: <PyAny >( value) ;
272
274
let value = value. extract( ) ?;
273
275
let result = slf. __setitem__( key. into( ) , value) . into( ) ;
274
- crate :: callback:: convert( py, result)
276
+ callback:: convert( py, result)
275
277
} )
276
278
}
277
279
Some ( wrap :: < T > )
@@ -304,10 +306,10 @@ mod sq_ass_item_impl {
304
306
where
305
307
T : for < ' p > PySequenceDelItemProtocol < ' p > ,
306
308
{
307
- let py = crate :: Python :: assume_gil_acquired ( ) ;
308
- crate :: catch_unwind!( py, {
309
- let _pool = crate :: GILPool :: new( py) ;
310
- let slf = py. from_borrowed_ptr:: <crate :: PyCell <T >>( slf) ;
309
+ let py = Python :: assume_gil_acquired ( ) ;
310
+ catch_unwind ! ( py, {
311
+ let _pool = GILPool :: new( py) ;
312
+ let slf = py. from_borrowed_ptr:: <PyCell <T >>( slf) ;
311
313
312
314
let result = if value. is_null( ) {
313
315
slf. borrow_mut( ) . __delitem__( key. into( ) ) . into( )
@@ -318,7 +320,7 @@ mod sq_ass_item_impl {
318
320
) ) )
319
321
} ;
320
322
321
- crate :: callback:: convert( py, result)
323
+ callback:: convert( py, result)
322
324
} )
323
325
}
324
326
Some ( wrap :: < T > )
@@ -351,10 +353,10 @@ mod sq_ass_item_impl {
351
353
where
352
354
T : for < ' p > PySequenceSetItemProtocol < ' p > + for < ' p > PySequenceDelItemProtocol < ' p > ,
353
355
{
354
- let py = crate :: Python :: assume_gil_acquired ( ) ;
355
- crate :: catch_unwind!( py, {
356
- let _pool = crate :: GILPool :: new( py) ;
357
- let slf = py. from_borrowed_ptr:: <crate :: PyCell <T >>( slf) ;
356
+ let py = Python :: assume_gil_acquired ( ) ;
357
+ catch_unwind ! ( py, {
358
+ let _pool = GILPool :: new( py) ;
359
+ let slf = py. from_borrowed_ptr:: <PyCell <T >>( slf) ;
358
360
359
361
let result = if value. is_null( ) {
360
362
call_mut!( slf, __delitem__; key. into( ) )
@@ -364,7 +366,7 @@ mod sq_ass_item_impl {
364
366
let value = value. extract( ) ?;
365
367
slf_. __setitem__( key. into( ) , value) . into( )
366
368
} ;
367
- crate :: callback:: convert( py, result)
369
+ callback:: convert( py, result)
368
370
} )
369
371
}
370
372
Some ( wrap :: < T > )
@@ -459,7 +461,7 @@ where
459
461
py_binary_func ! (
460
462
PySequenceInplaceConcatProtocol ,
461
463
T :: __inplace_concat__,
462
- * mut crate :: ffi:: PyObject ,
464
+ * mut ffi:: PyObject ,
463
465
call_mut
464
466
)
465
467
}
0 commit comments