From 996305ac627273e548b4badc6da5f4f8da7c466b Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Wed, 22 Feb 2023 21:47:47 +0000 Subject: [PATCH] remove other deprecations from 0.17 --- src/conversion.rs | 28 ---------------------------- src/lib.rs | 2 -- src/type_object.rs | 34 ---------------------------------- src/types/capsule.rs | 6 ------ 4 files changed, 70 deletions(-) diff --git a/src/conversion.rs b/src/conversion.rs index 93f2c362..c5bda16f 100644 --- a/src/conversion.rs +++ b/src/conversion.rs @@ -135,34 +135,6 @@ pub trait ToPyObject { fn to_object(&self, py: Python<'_>) -> PyObject; } -/// A deprecated conversion trait which relied on the unstable `specialization` feature -/// of the Rust language. -#[deprecated( - since = "0.17.0", - note = "this trait is no longer used by PyO3, use ToPyObject or IntoPy" -)] -pub trait ToBorrowedObject: ToPyObject { - /// Converts self into a Python object and calls the specified closure - /// on the native FFI pointer underlying the Python object. - /// - /// May be more efficient than `to_object` because it does not need - /// to touch any reference counts when the input object already is a Python object. - fn with_borrowed_ptr(&self, py: Python<'_>, f: F) -> R - where - F: FnOnce(*mut ffi::PyObject) -> R, - { - let ptr = self.to_object(py).into_ptr(); - let result = f(ptr); - unsafe { - ffi::Py_XDECREF(ptr); - } - result - } -} - -#[allow(deprecated)] -impl ToBorrowedObject for T where T: ToPyObject {} - /// Defines a conversion from a Rust type to a Python object. /// /// It functions similarly to std's [`Into`](std::convert::Into) trait, diff --git a/src/lib.rs b/src/lib.rs index f66bf1d1..ded43370 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -300,8 +300,6 @@ //! [Features chapter of the guide]: https://pyo3.rs/latest/features.html#features-reference "Features Reference - PyO3 user guide" //! [`Ungil`]: crate::marker::Ungil pub use crate::class::*; -#[allow(deprecated)] -pub use crate::conversion::ToBorrowedObject; pub use crate::conversion::{ AsPyPointer, FromPyObject, FromPyPointer, IntoPy, IntoPyPointer, PyTryFrom, PyTryInto, ToPyObject, diff --git a/src/type_object.rs b/src/type_object.rs index a4a84d6b..82e97503 100644 --- a/src/type_object.rs +++ b/src/type_object.rs @@ -62,20 +62,6 @@ pub unsafe trait PyTypeInfo: Sized { } } -/// Legacy trait which previously held the `type_object` method now found on `PyTypeInfo`. -/// -/// # Safety -/// -/// This trait used to have stringent safety requirements, but they are now irrelevant as it is deprecated. -#[deprecated( - since = "0.17.0", - note = "PyTypeObject::type_object was moved to PyTypeInfo::type_object" -)] -pub unsafe trait PyTypeObject: PyTypeInfo {} - -#[allow(deprecated)] -unsafe impl PyTypeObject for T {} - #[inline] pub(crate) unsafe fn get_tp_alloc(tp: *mut ffi::PyTypeObject) -> Option { #[cfg(not(Py_LIMITED_API))] @@ -104,23 +90,3 @@ pub(crate) unsafe fn get_tp_free(tp: *mut ffi::PyTypeObject) -> ffi::freefunc { std::mem::transmute(ptr) } } - -#[cfg(test)] -mod tests { - #[test] - #[allow(deprecated)] - fn test_deprecated_type_object() { - // Even though PyTypeObject is deprecated, simple usages of it as a trait bound should continue to work. - use super::PyTypeObject; - use crate::types::{PyList, PyType}; - use crate::Python; - - fn get_type_object(py: Python<'_>) -> &PyType { - T::type_object(py) - } - - Python::with_gil(|py| { - assert!(get_type_object::(py).is(::type_object(py))) - }); - } -} diff --git a/src/types/capsule.rs b/src/types/capsule.rs index 4136e52d..7da59e73 100644 --- a/src/types/capsule.rs +++ b/src/types/capsule.rs @@ -198,12 +198,6 @@ impl PyCapsule { Ok(ctx) } - /// Deprecated form of `.context()`. - #[deprecated(since = "0.17.0", note = "replaced with .context()")] - pub fn get_context(&self, _: Python<'_>) -> PyResult<*mut c_void> { - self.context() - } - /// Obtains a reference to the value of this capsule. /// /// # Safety