@@ -126,7 +126,9 @@ use crate::types::{
126126 PyAny , PyDict , PyEllipsis , PyModule , PyNone , PyNotImplemented , PyString , PyType ,
127127} ;
128128use 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 } ;
130132#[ allow( deprecated) ]
131133use crate :: { gil:: GILPool , FromPyPointer } ;
132134use std:: ffi:: { CStr , CString } ;
@@ -305,7 +307,7 @@ pub use nightly::Ungil;
305307/// A marker token that represents holding the GIL.
306308///
307309/// 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 `].
309311/// - It can be passed to functions that require a proof of holding the GIL, such as
310312/// [`Py::clone_ref`].
311313/// - Its lifetime represents the scope of holding the GIL which can be used to create Rust
@@ -321,7 +323,7 @@ pub use nightly::Ungil;
321323/// - In a function or method annotated with [`#[pyfunction]`](crate::pyfunction) or [`#[pymethods]`](crate::pymethods) you can declare it
322324/// as a parameter, and PyO3 will pass in the token when Python code calls it.
323325/// - 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.
325327/// - When you need to acquire the GIL yourself, such as when calling Python code from Rust, you
326328/// should call [`Python::with_gil`] to do that and pass your code as a closure to it.
327329///
@@ -352,7 +354,7 @@ pub use nightly::Ungil;
352354/// # Releasing and freeing memory
353355///
354356/// 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
356358/// references are tied to a [`GILPool`] whose references are not cleared until it is dropped.
357359/// This can cause apparent "memory leaks" if it is kept around for a long time.
358360///
@@ -552,12 +554,10 @@ impl<'py> Python<'py> {
552554 }
553555
554556 /// 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"
561561 ) ]
562562 pub fn eval (
563563 self ,
@@ -601,12 +601,10 @@ impl<'py> Python<'py> {
601601 }
602602
603603 /// 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"
610608 ) ]
611609 pub fn run (
612610 self ,
@@ -728,12 +726,10 @@ impl<'py> Python<'py> {
728726 }
729727
730728 /// 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"
737733 ) ]
738734 #[ inline]
739735 pub fn get_type < T > ( self ) -> & ' py PyType
@@ -753,12 +749,10 @@ impl<'py> Python<'py> {
753749 }
754750
755751 /// 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"
762756 ) ]
763757 pub fn import < N > ( self , name : N ) -> PyResult < & ' py PyModule >
764758 where
0 commit comments