feature gate deprecated APIs for `PyBuffer` (#4144)

This commit is contained in:
Alex Gaynor 2024-05-01 08:18:12 -04:00 committed by GitHub
parent dc9a41521a
commit 5534a7bee8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 7 deletions

View File

@ -18,8 +18,10 @@
// DEALINGS IN THE SOFTWARE.
//! `PyBuffer` implementation
use crate::Bound;
#[cfg(feature = "gil-refs")]
use crate::PyNativeType;
use crate::{err, exceptions::PyBufferError, ffi, FromPyObject, PyAny, PyResult, Python};
use crate::{Bound, PyNativeType};
use std::marker::PhantomData;
use std::os::raw;
use std::pin::Pin;
@ -190,12 +192,10 @@ impl<'py, T: Element> FromPyObject<'py> for PyBuffer<T> {
impl<T: Element> PyBuffer<T> {
/// Deprecated form of [`PyBuffer::get_bound`]
#[cfg_attr(
not(feature = "gil-refs"),
deprecated(
since = "0.21.0",
note = "`PyBuffer::get` will be replaced by `PyBuffer::get_bound` in a future PyO3 version"
)
#[cfg(feature = "gil-refs")]
#[deprecated(
since = "0.21.0",
note = "`PyBuffer::get` will be replaced by `PyBuffer::get_bound` in a future PyO3 version"
)]
pub fn get(obj: &PyAny) -> PyResult<PyBuffer<T>> {
Self::get_bound(&obj.as_borrowed())