@@ -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
+ use crate :: { ffi, Bound , IntoPy , Py , PyObject , PyTypeInfo } ;
130
+ #[ cfg( feature = "gil-refs" ) ]
131
+ use crate :: PyNativeType ;
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,13 +554,13 @@ 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
+ #[ cfg ( feature = "gil-refs" ) ]
558
+ # [
557
559
deprecated(
558
560
since = "0.21.0" ,
559
561
note = "`Python::eval` will be replaced by `Python::eval_bound` in a future PyO3 version"
560
562
)
561
- ) ]
563
+ ]
562
564
pub fn eval (
563
565
self ,
564
566
code : & str ,
@@ -601,13 +603,13 @@ impl<'py> Python<'py> {
601
603
}
602
604
603
605
/// Deprecated version of [`Python::run_bound`]
604
- #[ cfg_attr (
605
- not ( feature = "gil-refs" ) ,
606
+ #[ cfg ( feature = "gil-refs" ) ]
607
+ # [
606
608
deprecated(
607
609
since = "0.21.0" ,
608
610
note = "`Python::run` will be replaced by `Python::run_bound` in a future PyO3 version"
609
611
)
610
- ) ]
612
+ ]
611
613
pub fn run (
612
614
self ,
613
615
code : & str ,
@@ -728,13 +730,13 @@ impl<'py> Python<'py> {
728
730
}
729
731
730
732
/// Gets the Python type object for type `T`.
731
- #[ cfg_attr (
732
- not ( feature = "gil-refs" ) ,
733
+ #[ cfg ( feature = "gil-refs" ) ]
734
+ # [
733
735
deprecated(
734
736
since = "0.21.0" ,
735
737
note = "`Python::get_type` will be replaced by `Python::get_type_bound` in a future PyO3 version"
736
738
)
737
- ) ]
739
+ ]
738
740
#[ inline]
739
741
pub fn get_type < T > ( self ) -> & ' py PyType
740
742
where
@@ -753,13 +755,13 @@ impl<'py> Python<'py> {
753
755
}
754
756
755
757
/// Deprecated form of [`Python::import_bound`]
756
- #[ cfg_attr (
757
- not ( feature = "gil-refs" ) ,
758
+ #[ cfg ( feature = "gil-refs" ) ]
759
+ # [
758
760
deprecated(
759
761
since = "0.21.0" ,
760
762
note = "`Python::import` will be replaced by `Python::import_bound` in a future PyO3 version"
761
763
)
762
- ) ]
764
+ ]
763
765
pub fn import < N > ( self , name : N ) -> PyResult < & ' py PyModule >
764
766
where
765
767
N : IntoPy < Py < PyString > > ,
0 commit comments