remove other deprecations from 0.17

This commit is contained in:
David Hewitt 2023-02-22 21:47:47 +00:00 committed by Adam Reichold
parent dd24c9ea71
commit 996305ac62
4 changed files with 0 additions and 70 deletions

View file

@ -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<PyObject>"
)]
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<F, R>(&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<T> 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,

View file

@ -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,

View file

@ -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<T: PyTypeInfo> PyTypeObject for T {}
#[inline]
pub(crate) unsafe fn get_tp_alloc(tp: *mut ffi::PyTypeObject) -> Option<ffi::allocfunc> {
#[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<T: PyTypeObject>(py: Python<'_>) -> &PyType {
T::type_object(py)
}
Python::with_gil(|py| {
assert!(get_type_object::<PyList>(py).is(<PyList as crate::PyTypeInfo>::type_object(py)))
});
}
}

View file

@ -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