Skip to content

Commit c951bf8

Browse files
authored
feature gate deprecated APIs for PyCapsule (#4112)
1 parent 013a447 commit c951bf8

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/types/capsule.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ pyobject_native_type_core!(PyCapsule, pyobject_native_static_type_object!(ffi::P
4747

4848
impl PyCapsule {
4949
/// Deprecated form of [`PyCapsule::new_bound`].
50-
#[cfg_attr(
51-
not(feature = "gil-refs"),
52-
deprecated(
53-
since = "0.21.0",
54-
note = "`PyCapsule::new` will be replaced by `PyCapsule::new_bound` in a future PyO3 version"
55-
)
50+
#[cfg(feature = "gil-refs")]
51+
#[deprecated(
52+
since = "0.21.0",
53+
note = "`PyCapsule::new` will be replaced by `PyCapsule::new_bound` in a future PyO3 version"
5654
)]
5755
pub fn new<T: 'static + Send + AssertNotZeroSized>(
5856
py: Python<'_>,
@@ -102,12 +100,10 @@ impl PyCapsule {
102100
}
103101

104102
/// Deprecated form of [`PyCapsule::new_bound_with_destructor`].
105-
#[cfg_attr(
106-
not(feature = "gil-refs"),
107-
deprecated(
108-
since = "0.21.0",
109-
note = "`PyCapsule::new_with_destructor` will be replaced by `PyCapsule::new_bound_with_destructor` in a future PyO3 version"
110-
)
103+
#[cfg(feature = "gil-refs")]
104+
#[deprecated(
105+
since = "0.21.0",
106+
note = "`PyCapsule::new_with_destructor` will be replaced by `PyCapsule::new_bound_with_destructor` in a future PyO3 version"
111107
)]
112108
pub fn new_with_destructor<
113109
T: 'static + Send + AssertNotZeroSized,
@@ -441,7 +437,6 @@ fn name_ptr_ignore_error(slf: &Bound<'_, PyCapsule>) -> *const c_char {
441437
}
442438

443439
#[cfg(test)]
444-
#[cfg_attr(not(feature = "gil-refs"), allow(deprecated))]
445440
mod tests {
446441
use libc::c_void;
447442

0 commit comments

Comments
 (0)