Skip to content

Commit

Permalink
remove functionality deprecated in 0.16
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Dec 27, 2022
1 parent 1598991 commit d1ffec0
Show file tree
Hide file tree
Showing 11 changed files with 5 additions and 201 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 2 additions & 6 deletions guide/src/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ assert!(m.as_ref(py).downcast::<PyMapping>().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).
Expand Down Expand Up @@ -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]
Expand All @@ -859,7 +856,6 @@ impl PySequenceProtocol for ByteSequence {
Ok(Self { elements })
}
}
}
```

[`FromPyObject`]: {{#PYO3_DOCS_URL}}/pyo3/conversion/trait.FromPyObject.html
Expand Down
1 change: 1 addition & 0 deletions newsfragments/2843.removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove all functionality deprecated in PyO3 0.16.
71 changes: 0 additions & 71 deletions pyo3-build-config/src/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<CrossCompileConfig>> {
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:
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 2 additions & 4 deletions pyo3-build-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions pyo3-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 0 additions & 8 deletions pyo3-macros-backend/src/pyclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ enum PyClassPyO3Option {
TextSignature(TextSignatureAttribute),
Unsendable(kw::unsendable),
Weakref(kw::weakref),

DeprecatedGC(kw::gc),
}

impl Parse for PyClassPyO3Option {
Expand Down Expand Up @@ -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())
}
Expand Down Expand Up @@ -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(())
}
Expand Down
75 changes: 0 additions & 75 deletions src/err/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PyBaseException> {
self.into_value(py)
}
}

impl std::fmt::Debug for PyErr {
Expand Down Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions src/impl_/deprecations.rs
Original file line number Diff line number Diff line change
@@ -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)]`"
Expand Down
24 changes: 0 additions & 24 deletions src/types/typeobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: AsPyPointer>(&self, obj: &T) -> PyResult<bool> {
let any: &PyAny = unsafe { self.py().from_borrowed_ptr(obj.as_ptr()) };
any.is_instance(self)
}
}

#[cfg(test)]
Expand All @@ -93,15 +80,4 @@ mod tests {
assert!(py.get_type::<PyBool>().is_subclass_of::<PyLong>().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());
})
}
}
3 changes: 0 additions & 3 deletions tests/ui/deprecations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

use pyo3::prelude::*;

#[pyclass(gc)]
struct DeprecatedGc;

#[pyfunction(_opt = "None", x = "5")]
fn function_with_args(_opt: Option<i32>, _x: i32) {}

Expand Down

0 comments on commit d1ffec0

Please sign in to comment.