@@ -126,7 +126,9 @@ use crate::types::{
126
126
PyAny , PyDict , PyEllipsis , PyModule , PyNone , PyNotImplemented , PyString , PyType ,
127
127
} ;
128
128
use crate :: version:: PythonVersionInfo ;
129
- use crate :: { ffi, Bound , IntoPy , Py , PyNativeType , PyObject , PyTypeInfo } ;
129
+ #[ cfg( feature = "gil-refs" ) ]
130
+ use crate :: PyNativeType ;
131
+ use crate :: { ffi, Bound , IntoPy , Py , PyObject , PyTypeInfo } ;
130
132
#[ allow( deprecated) ]
131
133
use crate :: { gil:: GILPool , FromPyPointer } ;
132
134
use std:: ffi:: { CStr , CString } ;
@@ -305,7 +307,7 @@ pub use nightly::Ungil;
305
307
/// A marker token that represents holding the GIL.
306
308
///
307
309
/// It serves three main purposes:
308
- /// - It provides a global API for the Python interpreter, such as [`Python::eval `].
310
+ /// - It provides a global API for the Python interpreter, such as [`Python::eval_bound `].
309
311
/// - It can be passed to functions that require a proof of holding the GIL, such as
310
312
/// [`Py::clone_ref`].
311
313
/// - Its lifetime represents the scope of holding the GIL which can be used to create Rust
@@ -321,7 +323,7 @@ pub use nightly::Ungil;
321
323
/// - In a function or method annotated with [`#[pyfunction]`](crate::pyfunction) or [`#[pymethods]`](crate::pymethods) you can declare it
322
324
/// as a parameter, and PyO3 will pass in the token when Python code calls it.
323
325
/// - If you already have something with a lifetime bound to the GIL, such as `&`[`PyAny`], you can
324
- /// use its [ `.py()`][PyAny::py] method to get a token.
326
+ /// use its `.py()` method to get a token.
325
327
/// - When you need to acquire the GIL yourself, such as when calling Python code from Rust, you
326
328
/// should call [`Python::with_gil`] to do that and pass your code as a closure to it.
327
329
///
@@ -352,7 +354,7 @@ pub use nightly::Ungil;
352
354
/// # Releasing and freeing memory
353
355
///
354
356
/// The [`Python`] type can be used to create references to variables owned by the Python
355
- /// interpreter, using functions such as [ `Python::eval`] and `PyModule::import`. These
357
+ /// interpreter, using functions such as `Python::eval` and `PyModule::import`. These
356
358
/// references are tied to a [`GILPool`] whose references are not cleared until it is dropped.
357
359
/// This can cause apparent "memory leaks" if it is kept around for a long time.
358
360
///
@@ -552,12 +554,10 @@ impl<'py> Python<'py> {
552
554
}
553
555
554
556
/// Deprecated version of [`Python::eval_bound`]
555
- #[ cfg_attr(
556
- not( feature = "gil-refs" ) ,
557
- deprecated(
558
- since = "0.21.0" ,
559
- note = "`Python::eval` will be replaced by `Python::eval_bound` in a future PyO3 version"
560
- )
557
+ #[ cfg( feature = "gil-refs" ) ]
558
+ #[ deprecated(
559
+ since = "0.21.0" ,
560
+ note = "`Python::eval` will be replaced by `Python::eval_bound` in a future PyO3 version"
561
561
) ]
562
562
pub fn eval (
563
563
self ,
@@ -601,12 +601,10 @@ impl<'py> Python<'py> {
601
601
}
602
602
603
603
/// Deprecated version of [`Python::run_bound`]
604
- #[ cfg_attr(
605
- not( feature = "gil-refs" ) ,
606
- deprecated(
607
- since = "0.21.0" ,
608
- note = "`Python::run` will be replaced by `Python::run_bound` in a future PyO3 version"
609
- )
604
+ #[ cfg( feature = "gil-refs" ) ]
605
+ #[ deprecated(
606
+ since = "0.21.0" ,
607
+ note = "`Python::run` will be replaced by `Python::run_bound` in a future PyO3 version"
610
608
) ]
611
609
pub fn run (
612
610
self ,
@@ -728,12 +726,10 @@ impl<'py> Python<'py> {
728
726
}
729
727
730
728
/// Gets the Python type object for type `T`.
731
- #[ cfg_attr(
732
- not( feature = "gil-refs" ) ,
733
- deprecated(
734
- since = "0.21.0" ,
735
- note = "`Python::get_type` will be replaced by `Python::get_type_bound` in a future PyO3 version"
736
- )
729
+ #[ cfg( feature = "gil-refs" ) ]
730
+ #[ deprecated(
731
+ since = "0.21.0" ,
732
+ note = "`Python::get_type` will be replaced by `Python::get_type_bound` in a future PyO3 version"
737
733
) ]
738
734
#[ inline]
739
735
pub fn get_type < T > ( self ) -> & ' py PyType
@@ -753,12 +749,10 @@ impl<'py> Python<'py> {
753
749
}
754
750
755
751
/// Deprecated form of [`Python::import_bound`]
756
- #[ cfg_attr(
757
- not( feature = "gil-refs" ) ,
758
- deprecated(
759
- since = "0.21.0" ,
760
- note = "`Python::import` will be replaced by `Python::import_bound` in a future PyO3 version"
761
- )
752
+ #[ cfg( feature = "gil-refs" ) ]
753
+ #[ deprecated(
754
+ since = "0.21.0" ,
755
+ note = "`Python::import` will be replaced by `Python::import_bound` in a future PyO3 version"
762
756
) ]
763
757
pub fn import < N > ( self , name : N ) -> PyResult < & ' py PyModule >
764
758
where
0 commit comments