diff --git a/Cargo.toml b/Cargo.toml index 08b863db650..6c24de5d906 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,8 +84,6 @@ abi3-py311 = ["abi3", "pyo3-build-config/abi3-py311", "pyo3-ffi/abi3-py311"] # Automatically generates `python3.dll` import libraries for Windows targets. generate-import-lib = ["pyo3-ffi/generate-import-lib"] -# Deprecated, replaced by `generate-import-lib` -generate-abi3-import-lib = ["generate-import-lib"] # Changes `Python::with_gil` and `Python::acquire_gil` to automatically initialize the # Python interpreter if needed. diff --git a/guide/src/migration.md b/guide/src/migration.md index c0040a709cd..c5d2bc5de34 100644 --- a/guide/src/migration.md +++ b/guide/src/migration.md @@ -56,7 +56,7 @@ assert!(m.as_ref(py).downcast::().is_ok()); Note that this requirement may go away in the future when a pyclass is able to inherit from the abstract base class directly (see [pyo3/pyo3#991](https://github.com/PyO3/pyo3/issues/991)). -### The `multiple-pymethods` feature now requires Rust 1.62 +### The `multiple-pymethods` feature now requires Rust 1.62 Due to limitations in the `inventory` crate which the `multiple-pymethods` feature depends on, this feature now requires Rust 1.62. For more information see [dtolnay/inventory#32](https://github.com/dtolnay/inventory/issues/32). @@ -841,10 +841,7 @@ impl PySequenceProtocol for ByteSequence { ``` After: -```rust -# #[allow(deprecated)] -# #[cfg(feature = "pyproto")] -# { +```rust,compile_fail # use pyo3::prelude::*; # use pyo3::class::PySequenceProtocol; #[pyclass] @@ -859,7 +856,6 @@ impl PySequenceProtocol for ByteSequence { Ok(Self { elements }) } } -} ``` [`FromPyObject`]: {{#PYO3_DOCS_URL}}/pyo3/conversion/trait.FromPyObject.html diff --git a/newsfragments/2843.removed.md b/newsfragments/2843.removed.md new file mode 100644 index 00000000000..bd7d399b954 --- /dev/null +++ b/newsfragments/2843.removed.md @@ -0,0 +1 @@ +Remove all functionality deprecated in PyO3 0.16. diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs index 53b4aeb846f..dcd9cf38e0b 100644 --- a/pyo3-build-config/src/impl_.rs +++ b/pyo3-build-config/src/impl_.rs @@ -907,57 +907,6 @@ impl CrossCompileEnvVars { } } -/// Detect whether we are cross compiling and return an assembled CrossCompileConfig if so. -/// -/// This function relies on PyO3 cross-compiling environment variables: -/// -/// * `PYO3_CROSS`: If present, forces PyO3 to configure as a cross-compilation. -/// * `PYO3_CROSS_LIB_DIR`: If present, must be set to the directory containing -/// the target's libpython DSO and the associated `_sysconfigdata*.py` file for -/// Unix-like targets, or the Python DLL import libraries for the Windows target. -/// * `PYO3_CROSS_PYTHON_VERSION`: Major and minor version (e.g. 3.9) of the target Python -/// installation. This variable is only needed if PyO3 cannnot determine the version to target -/// from `abi3-py3*` features, or if there are multiple versions of Python present in -/// `PYO3_CROSS_LIB_DIR`. -/// -/// See the [PyO3 User Guide](https://pyo3.rs/) for more info on cross-compiling. -#[deprecated( - since = "0.16.3", - note = "please use cross_compiling_from_to() instead" -)] -pub fn cross_compiling( - host: &str, - target_arch: &str, - target_vendor: &str, - target_os: &str, -) -> Result> { - let host: Triple = host.parse().map_err(|_| "bad host triple")?; - - let architecture: Architecture = target_arch.parse().map_err(|_| "bad target arch")?; - let vendor: Vendor = target_vendor.parse().map_err(|_| "bad target vendor")?; - let operating_system: OperatingSystem = target_os.parse().map_err(|_| "bad target os")?; - - // FIXME: This is a very bad approximation that only works - // for the current `CrossCompileConfig` implementation. - let environment = match operating_system { - OperatingSystem::Windows => Environment::Msvc, - _ => Environment::Gnu, - }; - - // FIXME: This field is currently unused. - let binary_format = BinaryFormat::Elf; - - let target = Triple { - architecture, - vendor, - operating_system, - environment, - binary_format, - }; - - cross_compiling_from_to(&host, &target) -} - /// Detect whether we are cross compiling and return an assembled CrossCompileConfig if so. /// /// This function relies on PyO3 cross-compiling environment variables: @@ -2516,26 +2465,6 @@ mod tests { ); } - #[test] - #[allow(deprecated)] - fn test_not_cross_compiling() { - assert!( - cross_compiling("aarch64-apple-darwin", "x86_64", "apple", "darwin") - .unwrap() - .is_none() - ); - assert!( - cross_compiling("x86_64-apple-darwin", "aarch64", "apple", "darwin") - .unwrap() - .is_none() - ); - assert!( - cross_compiling("x86_64-unknown-linux-gnu", "x86_64", "unknown", "linux") - .unwrap() - .is_none() - ); - } - #[test] fn test_not_cross_compiling_from_to() { assert!(cross_compiling_from_to( diff --git a/pyo3-build-config/src/lib.rs b/pyo3-build-config/src/lib.rs index 8a6f11248db..9bcaf34e3a6 100644 --- a/pyo3-build-config/src/lib.rs +++ b/pyo3-build-config/src/lib.rs @@ -21,11 +21,9 @@ use std::{env, process::Command, str::FromStr}; #[cfg(feature = "resolve-config")] use once_cell::sync::OnceCell; -#[allow(deprecated)] pub use impl_::{ - cross_compiling, cross_compiling_from_to, find_all_sysconfigdata, parse_sysconfigdata, - BuildFlag, BuildFlags, CrossCompileConfig, InterpreterConfig, PythonImplementation, - PythonVersion, Triple, + cross_compiling_from_to, find_all_sysconfigdata, parse_sysconfigdata, BuildFlag, BuildFlags, + CrossCompileConfig, InterpreterConfig, PythonImplementation, PythonVersion, Triple, }; use target_lexicon::OperatingSystem; diff --git a/pyo3-ffi/Cargo.toml b/pyo3-ffi/Cargo.toml index 7fb95be5be1..846cda6fe6b 100644 --- a/pyo3-ffi/Cargo.toml +++ b/pyo3-ffi/Cargo.toml @@ -35,8 +35,6 @@ abi3-py311 = ["abi3", "pyo3-build-config/abi3-py311"] # Automatically generates `python3.dll` import libraries for Windows targets. generate-import-lib = ["pyo3-build-config/python3-dll-a"] -# Deprecated, replaced by `generate-import-lib` -generate-abi3-import-lib = ["generate-import-lib"] [build-dependencies] diff --git a/pyo3-macros-backend/src/pyclass.rs b/pyo3-macros-backend/src/pyclass.rs index bfc9a5f1f84..5224c2c4498 100644 --- a/pyo3-macros-backend/src/pyclass.rs +++ b/pyo3-macros-backend/src/pyclass.rs @@ -93,8 +93,6 @@ enum PyClassPyO3Option { TextSignature(TextSignatureAttribute), Unsendable(kw::unsendable), Weakref(kw::weakref), - - DeprecatedGC(kw::gc), } impl Parse for PyClassPyO3Option { @@ -130,8 +128,6 @@ impl Parse for PyClassPyO3Option { input.parse().map(PyClassPyO3Option::Unsendable) } else if lookahead.peek(attributes::kw::weakref) { input.parse().map(PyClassPyO3Option::Weakref) - } else if lookahead.peek(attributes::kw::gc) { - input.parse().map(PyClassPyO3Option::DeprecatedGC) } else { Err(lookahead.error()) } @@ -184,10 +180,6 @@ impl PyClassPyO3Options { PyClassPyO3Option::TextSignature(text_signature) => set_option!(text_signature), PyClassPyO3Option::Unsendable(unsendable) => set_option!(unsendable), PyClassPyO3Option::Weakref(weakref) => set_option!(weakref), - - PyClassPyO3Option::DeprecatedGC(gc) => self - .deprecations - .push(Deprecation::PyClassGcOption, gc.span()), } Ok(()) } diff --git a/src/err/mod.rs b/src/err/mod.rs index 4acf4497b70..8d73556ede4 100644 --- a/src/err/mod.rs +++ b/src/err/mod.rs @@ -661,57 +661,6 @@ impl PyErr { } } } - - /// Deprecated name for [`PyErr::get_type`]. - #[deprecated( - since = "0.16.0", - note = "Use err.get_type(py) instead of err.ptype(py)" - )] - pub fn ptype<'py>(&'py self, py: Python<'py>) -> &'py PyType { - self.get_type(py) - } - - /// Deprecated name for [`PyErr::value`]. - #[deprecated(since = "0.16.0", note = "Use err.value(py) instead of err.pvalue(py)")] - pub fn pvalue<'py>(&'py self, py: Python<'py>) -> &'py PyBaseException { - self.value(py) - } - - /// Deprecated name for [`PyErr::traceback`]. - #[deprecated( - since = "0.16.0", - note = "Use err.traceback(py) instead of err.ptraceback(py)" - )] - pub fn ptraceback<'py>(&'py self, py: Python<'py>) -> Option<&'py PyTraceback> { - self.traceback(py) - } - - /// Deprecated name for [`PyErr::value`]. - #[deprecated( - since = "0.16.0", - note = "Use err.value(py) instead of err.instance(py)" - )] - pub fn instance<'py>(&'py self, py: Python<'py>) -> &'py PyBaseException { - self.value(py) - } - - /// Deprecated name for [`PyErr::from_value`]. - #[deprecated( - since = "0.16.0", - note = "Use err.from_value(py, obj) instead of err.from_instance(py, obj)" - )] - pub fn from_instance(value: &PyAny) -> PyErr { - PyErr::from_value(value) - } - - /// Deprecated name for [`PyErr::into_value`]. - #[deprecated( - since = "0.16.0", - note = "Use err.into_value(py) instead of err.into_instance(py)" - )] - pub fn into_instance(self, py: Python<'_>) -> Py { - self.into_value(py) - } } impl std::fmt::Debug for PyErr { @@ -977,30 +926,6 @@ mod tests { }); } - #[allow(deprecated)] - #[test] - fn deprecations() { - let err = exceptions::PyValueError::new_err("an error"); - Python::with_gil(|py| { - assert_eq!(err.ptype(py).as_ptr(), err.get_type(py).as_ptr()); - assert_eq!(err.pvalue(py).as_ptr(), err.value(py).as_ptr()); - assert_eq!(err.instance(py).as_ptr(), err.value(py).as_ptr()); - assert_eq!( - err.ptraceback(py).map(|t| t.as_ptr()), - err.traceback(py).map(|t| t.as_ptr()) - ); - - assert_eq!( - err.clone_ref(py).into_instance(py).as_ref(py).as_ptr(), - err.value(py).as_ptr() - ); - assert_eq!( - PyErr::from_instance(err.value(py)).value(py).as_ptr(), - err.value(py).as_ptr() - ); - }); - } - #[test] fn warnings() { // Note: although the warning filter is interpreter global, keeping the diff --git a/src/impl_/deprecations.rs b/src/impl_/deprecations.rs index 6a24c4ce527..1cda64d422b 100644 --- a/src/impl_/deprecations.rs +++ b/src/impl_/deprecations.rs @@ -1,11 +1,5 @@ //! Symbols used to denote deprecated usages of PyO3's proc macros. -#[deprecated( - since = "0.16.0", - note = "implement a `__traverse__` `#[pymethod]` instead of using `gc` option" -)] -pub const PYCLASS_GC_OPTION: () = (); - #[deprecated( since = "0.18.0", note = "passing arbitrary arguments to `#[pyfunction()]` to specify the signature is being replaced by `#[pyo3(signature)]`" diff --git a/src/types/typeobject.rs b/src/types/typeobject.rs index 8c16b86d785..00ba62c3be1 100644 --- a/src/types/typeobject.rs +++ b/src/types/typeobject.rs @@ -58,19 +58,6 @@ impl PyType { { self.is_subclass(T::type_object(self.py())) } - - #[deprecated( - since = "0.16.0", - note = "prefer obj.is_instance(type) to typ.is_instance(obj)" - )] - /// Equivalent to Python's `isinstance(obj, self)`. - /// - /// This function has been deprecated because it has inverted argument ordering compared to - /// other `is_instance` functions in PyO3 such as [`PyAny::is_instance`]. - pub fn is_instance(&self, obj: &T) -> PyResult { - let any: &PyAny = unsafe { self.py().from_borrowed_ptr(obj.as_ptr()) }; - any.is_instance(self) - } } #[cfg(test)] @@ -93,15 +80,4 @@ mod tests { assert!(py.get_type::().is_subclass_of::().unwrap()); }); } - - #[test] - #[allow(deprecated)] - fn type_is_instance() { - Python::with_gil(|py| { - let bool_object = PyBool::new(py, false); - let bool_type = bool_object.get_type(); - assert!(bool_type.is_instance(bool_object).unwrap()); - assert!(bool_object.is_instance(bool_type).unwrap()); - }) - } } diff --git a/tests/ui/deprecations.rs b/tests/ui/deprecations.rs index 87e97184403..f5fb7a5db15 100644 --- a/tests/ui/deprecations.rs +++ b/tests/ui/deprecations.rs @@ -2,9 +2,6 @@ use pyo3::prelude::*; -#[pyclass(gc)] -struct DeprecatedGc; - #[pyfunction(_opt = "None", x = "5")] fn function_with_args(_opt: Option, _x: i32) {}