@@ -182,7 +182,7 @@ pub trait PyListMethods<'py>: crate::sealed::Sealed {
182
182
/// # Safety
183
183
///
184
184
/// Caller must verify that the index is within the bounds of the list.
185
- #[ cfg( not( Py_LIMITED_API ) ) ]
185
+ #[ cfg( not( any ( Py_LIMITED_API , Py_GIL_DISABLED ) ) ) ]
186
186
unsafe fn get_item_unchecked ( & self , index : usize ) -> Bound < ' py , PyAny > ;
187
187
188
188
/// Takes the slice `self[low:high]` and returns it as a new list.
@@ -305,7 +305,7 @@ impl<'py> PyListMethods<'py> for Bound<'py, PyList> {
305
305
/// # Safety
306
306
///
307
307
/// Caller must verify that the index is within the bounds of the list.
308
- #[ cfg( not( Py_LIMITED_API ) ) ]
308
+ #[ cfg( not( any ( Py_LIMITED_API , Py_GIL_DISABLED ) ) ) ]
309
309
unsafe fn get_item_unchecked ( & self , index : usize ) -> Bound < ' py , PyAny > {
310
310
// PyList_GET_ITEM return borrowed ptr; must make owned for safety (see #890).
311
311
ffi:: PyList_GET_ITEM ( self . as_ptr ( ) , index as Py_ssize_t )
@@ -496,9 +496,9 @@ impl<'py> BoundListIterator<'py> {
496
496
}
497
497
498
498
unsafe fn get_item ( & self , index : usize ) -> Bound < ' py , PyAny > {
499
- #[ cfg( any( Py_LIMITED_API , PyPy ) ) ]
499
+ #[ cfg( any( Py_LIMITED_API , PyPy , Py_GIL_DISABLED ) ) ]
500
500
let item = self . list . get_item ( index) . expect ( "list.get failed" ) ;
501
- #[ cfg( not( any( Py_LIMITED_API , PyPy ) ) ) ]
501
+ #[ cfg( not( any( Py_LIMITED_API , PyPy , Py_GIL_DISABLED ) ) ) ]
502
502
let item = self . list . get_item_unchecked ( index) ;
503
503
item
504
504
}
@@ -893,7 +893,7 @@ mod tests {
893
893
} ) ;
894
894
}
895
895
896
- #[ cfg( not( any( Py_LIMITED_API , PyPy ) ) ) ]
896
+ #[ cfg( not( any( Py_LIMITED_API , PyPy , Py_GIL_DISABLED ) ) ) ]
897
897
#[ test]
898
898
fn test_list_get_item_unchecked_sanity ( ) {
899
899
Python :: with_gil ( |py| {
0 commit comments