Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/6068.removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove all functionality deprecated in PyO3 0.27.
183 changes: 0 additions & 183 deletions src/err/downcast_error.rs

This file was deleted.

3 changes: 0 additions & 3 deletions src/err/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@ use core::ffi::CStr;
use err_state::{PyErrState, PyErrStateLazyFnOutput, PyErrStateNormalized};

mod cast_error;
mod downcast_error;
mod err_state;
mod impls;

pub use cast_error::{CastError, CastIntoError};
#[allow(deprecated)]
pub use downcast_error::{DowncastError, DowncastIntoError};

/// Represents a Python exception.
///
Expand Down
9 changes: 0 additions & 9 deletions src/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,6 @@ macro_rules! import_exception {
};
}

/// Deprecated name for `import_exception!`.
#[macro_export]
#[deprecated(since = "0.27.0", note = "renamed to `import_exception!` instead")]
macro_rules! import_exception_bound {
($module: expr, $name: ident) => {
$crate::import_exception!($module, $name);
};
}

/// Defines a new exception type.
///
/// # Syntax
Expand Down
80 changes: 0 additions & 80 deletions src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use crate::pycell::{PyBorrowError, PyBorrowMutError};
use crate::pyclass::boolean_struct::{False, True};
use crate::types::{any::PyAnyMethods, string::PyStringMethods, typeobject::PyTypeMethods};
use crate::types::{DerefToPyAny, PyDict, PyString};
#[allow(deprecated)]
use crate::DowncastError;
use crate::{
ffi, CastError, CastIntoError, FromPyObject, PyAny, PyClass, PyClassInitializer, PyRef,
PyRefMut, PyTypeInfo, Python,
Expand Down Expand Up @@ -2352,84 +2350,6 @@ impl<T> core::fmt::Debug for Py<T> {
}
}

impl Py<PyAny> {
/// Downcast this `Py<PyAny>` to a concrete Python type or pyclass.
///
/// Note that you can often avoid casting yourself by just specifying the desired type in
/// function or method signatures. However, manual casting is sometimes necessary.
///
/// For extracting a Rust-only type, see [`Py::extract`].
///
/// # Example: Downcasting to a specific Python object
///
/// ```rust
/// # #![allow(deprecated)]
/// use pyo3::prelude::*;
/// use pyo3::types::{PyDict, PyList};
///
/// Python::attach(|py| {
/// let any = PyDict::new(py).into_any().unbind();
///
/// assert!(any.downcast_bound::<PyDict>(py).is_ok());
/// assert!(any.downcast_bound::<PyList>(py).is_err());
/// });
/// ```
///
/// # Example: Getting a reference to a pyclass
///
/// This is useful if you want to mutate a `Py<PyAny>` that might actually be a pyclass.
///
/// ```rust
/// # #![allow(deprecated)]
/// # fn main() -> Result<(), pyo3::PyErr> {
/// use pyo3::prelude::*;
///
/// #[pyclass]
/// struct Class {
/// i: i32,
/// }
///
/// Python::attach(|py| {
/// let class = Py::new(py, Class { i: 0 })?.into_any();
///
/// let class_bound = class.downcast_bound::<Class>(py)?;
///
/// class_bound.borrow_mut().i += 1;
///
/// // Alternatively you can get a `PyRefMut` directly
/// let class_ref: PyRefMut<'_, Class> = class.extract(py)?;
/// assert_eq!(class_ref.i, 1);
/// Ok(())
/// })
/// # }
/// ```
#[deprecated(since = "0.27.0", note = "use `Py::cast_bound` instead")]
#[inline]
#[allow(deprecated)]
pub fn downcast_bound<'py, T>(
&self,
py: Python<'py>,
) -> Result<&Bound<'py, T>, DowncastError<'_, 'py>>
where
T: PyTypeCheck,
{
#[allow(deprecated)]
self.bind(py).downcast()
}

/// Casts the `Py<PyAny>` to a concrete Python object type without checking validity.
///
/// # Safety
///
/// Callers must ensure that the type is valid or risk type confusion.
#[deprecated(since = "0.27.0", note = "use `Py::cast_bound_unchecked` instead")]
#[inline]
pub unsafe fn downcast_bound_unchecked<'py, T>(&self, py: Python<'py>) -> &Bound<'py, T> {
// SAFETY: caller has upheld the safety contract
unsafe { self.cast_bound_unchecked(py) }
}
}

impl<T> Py<T> {
/// Cast this `Py<T>` to a concrete Python type or pyclass.
///
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,6 @@ extern crate alloc;
pub use crate::class::*;
pub use crate::conversion::{FromPyObject, IntoPyObject, IntoPyObjectExt};
pub use crate::err::{CastError, CastIntoError, PyErr, PyErrArguments, PyResult, ToPyErr};
#[allow(deprecated)]
pub use crate::err::{DowncastError, DowncastIntoError};
pub use crate::instance::{Borrowed, Bound, BoundObject, Py};
#[cfg(not(any(PyPy, GraalPy)))]
pub use crate::interpreter_lifecycle::with_embedded_python_interpreter;
Expand Down
10 changes: 0 additions & 10 deletions src/type_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,6 @@ pub unsafe trait PyTypeInfo: Sized {
/// to a concrete type. The implementor is responsible for ensuring that `type_check` only returns
/// true for objects which can safely be treated as Python instances of `Self`.
pub unsafe trait PyTypeCheck {
/// Name of self. This is used in error messages, for example.
#[deprecated(
since = "0.27.0",
note = "Use ::classinfo_object() instead and format the type name at runtime. Note that using built-in cast features is often better than manual PyTypeCheck usage."
)]
const NAME: &'static str;

/// Provides the full python type of the allowed values as a Python type hint.
#[cfg(feature = "experimental-inspect")]
const TYPE_HINT: PyStaticExpr;
Expand All @@ -132,9 +125,6 @@ unsafe impl<T> PyTypeCheck for T
where
T: PyTypeInfo,
{
#[allow(deprecated)]
const NAME: &'static str = T::NAME;

#[cfg(feature = "experimental-inspect")]
const TYPE_HINT: PyStaticExpr = <T as PyTypeInfo>::TYPE_HINT;

Expand Down
Loading
Loading