Merge #2843
2843: remove functionality deprecated in 0.16 r=davidhewitt a=davidhewitt Simple cleanup to remove all functionality marked deprecated in the 0.16 releases. Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
This commit is contained in:
commit
cedb5aecb2
|
@ -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.
|
# Automatically generates `python3.dll` import libraries for Windows targets.
|
||||||
generate-import-lib = ["pyo3-ffi/generate-import-lib"]
|
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
|
# Changes `Python::with_gil` and `Python::acquire_gil` to automatically initialize the
|
||||||
# Python interpreter if needed.
|
# Python interpreter if needed.
|
||||||
|
|
|
@ -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)).
|
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
|
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).
|
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:
|
After:
|
||||||
```rust
|
```rust,compile_fail
|
||||||
# #[allow(deprecated)]
|
|
||||||
# #[cfg(feature = "pyproto")]
|
|
||||||
# {
|
|
||||||
# use pyo3::prelude::*;
|
# use pyo3::prelude::*;
|
||||||
# use pyo3::class::PySequenceProtocol;
|
# use pyo3::class::PySequenceProtocol;
|
||||||
#[pyclass]
|
#[pyclass]
|
||||||
|
@ -859,7 +856,6 @@ impl PySequenceProtocol for ByteSequence {
|
||||||
Ok(Self { elements })
|
Ok(Self { elements })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
[`FromPyObject`]: {{#PYO3_DOCS_URL}}/pyo3/conversion/trait.FromPyObject.html
|
[`FromPyObject`]: {{#PYO3_DOCS_URL}}/pyo3/conversion/trait.FromPyObject.html
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Remove all functionality deprecated in PyO3 0.16.
|
|
@ -22,7 +22,7 @@ use std::{
|
||||||
|
|
||||||
pub use target_lexicon::Triple;
|
pub use target_lexicon::Triple;
|
||||||
|
|
||||||
use target_lexicon::{Architecture, BinaryFormat, Environment, OperatingSystem, Vendor};
|
use target_lexicon::{Environment, OperatingSystem};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bail, ensure,
|
bail, ensure,
|
||||||
|
@ -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.
|
/// Detect whether we are cross compiling and return an assembled CrossCompileConfig if so.
|
||||||
///
|
///
|
||||||
/// This function relies on PyO3 cross-compiling environment variables:
|
/// 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]
|
#[test]
|
||||||
fn test_not_cross_compiling_from_to() {
|
fn test_not_cross_compiling_from_to() {
|
||||||
assert!(cross_compiling_from_to(
|
assert!(cross_compiling_from_to(
|
||||||
|
|
|
@ -4,11 +4,11 @@ use std::env;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use python3_dll_a::ImportLibraryGenerator;
|
use python3_dll_a::ImportLibraryGenerator;
|
||||||
|
use target_lexicon::{Architecture, OperatingSystem, Triple};
|
||||||
|
|
||||||
|
use super::{PythonImplementation, PythonVersion};
|
||||||
use crate::errors::{Context, Result};
|
use crate::errors::{Context, Result};
|
||||||
|
|
||||||
use super::{Architecture, OperatingSystem, PythonImplementation, PythonVersion, Triple};
|
|
||||||
|
|
||||||
/// Generates the `python3.dll` or `pythonXY.dll` import library for Windows targets.
|
/// Generates the `python3.dll` or `pythonXY.dll` import library for Windows targets.
|
||||||
///
|
///
|
||||||
/// Places the generated import library into the build script output directory
|
/// Places the generated import library into the build script output directory
|
||||||
|
|
|
@ -21,11 +21,9 @@ use std::{env, process::Command, str::FromStr};
|
||||||
#[cfg(feature = "resolve-config")]
|
#[cfg(feature = "resolve-config")]
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
|
|
||||||
#[allow(deprecated)]
|
|
||||||
pub use impl_::{
|
pub use impl_::{
|
||||||
cross_compiling, cross_compiling_from_to, find_all_sysconfigdata, parse_sysconfigdata,
|
cross_compiling_from_to, find_all_sysconfigdata, parse_sysconfigdata, BuildFlag, BuildFlags,
|
||||||
BuildFlag, BuildFlags, CrossCompileConfig, InterpreterConfig, PythonImplementation,
|
CrossCompileConfig, InterpreterConfig, PythonImplementation, PythonVersion, Triple,
|
||||||
PythonVersion, Triple,
|
|
||||||
};
|
};
|
||||||
use target_lexicon::OperatingSystem;
|
use target_lexicon::OperatingSystem;
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,6 @@ abi3-py311 = ["abi3", "pyo3-build-config/abi3-py311"]
|
||||||
|
|
||||||
# Automatically generates `python3.dll` import libraries for Windows targets.
|
# Automatically generates `python3.dll` import libraries for Windows targets.
|
||||||
generate-import-lib = ["pyo3-build-config/python3-dll-a"]
|
generate-import-lib = ["pyo3-build-config/python3-dll-a"]
|
||||||
# Deprecated, replaced by `generate-import-lib`
|
|
||||||
generate-abi3-import-lib = ["generate-import-lib"]
|
|
||||||
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
|
@ -4,7 +4,6 @@ use quote::{quote_spanned, ToTokens};
|
||||||
// Clippy complains all these variants have the same prefix "Py"...
|
// Clippy complains all these variants have the same prefix "Py"...
|
||||||
#[allow(clippy::enum_variant_names)]
|
#[allow(clippy::enum_variant_names)]
|
||||||
pub enum Deprecation {
|
pub enum Deprecation {
|
||||||
PyClassGcOption,
|
|
||||||
PyFunctionArguments,
|
PyFunctionArguments,
|
||||||
PyMethodArgsAttribute,
|
PyMethodArgsAttribute,
|
||||||
}
|
}
|
||||||
|
@ -12,7 +11,6 @@ pub enum Deprecation {
|
||||||
impl Deprecation {
|
impl Deprecation {
|
||||||
fn ident(&self, span: Span) -> syn::Ident {
|
fn ident(&self, span: Span) -> syn::Ident {
|
||||||
let string = match self {
|
let string = match self {
|
||||||
Deprecation::PyClassGcOption => "PYCLASS_GC_OPTION",
|
|
||||||
Deprecation::PyFunctionArguments => "PYFUNCTION_ARGUMENTS",
|
Deprecation::PyFunctionArguments => "PYFUNCTION_ARGUMENTS",
|
||||||
Deprecation::PyMethodArgsAttribute => "PYMETHODS_ARGS_ATTRIBUTE",
|
Deprecation::PyMethodArgsAttribute => "PYMETHODS_ARGS_ATTRIBUTE",
|
||||||
};
|
};
|
||||||
|
|
|
@ -709,7 +709,7 @@ fn parse_method_attributes(
|
||||||
deprecated_args.is_none(),
|
deprecated_args.is_none(),
|
||||||
nested.span() => "args may only be specified once"
|
nested.span() => "args may only be specified once"
|
||||||
);
|
);
|
||||||
deprecations.push(Deprecation::PyMethodArgsAttribute, nested.span());
|
deprecations.push(Deprecation::PyMethodArgsAttribute, path.span());
|
||||||
deprecated_args = Some(DeprecatedArgs::from_meta(&nested)?);
|
deprecated_args = Some(DeprecatedArgs::from_meta(&nested)?);
|
||||||
} else {
|
} else {
|
||||||
new_attrs.push(attr)
|
new_attrs.push(attr)
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::attributes::{
|
||||||
self, kw, take_pyo3_options, CrateAttribute, ExtendsAttribute, FreelistAttribute,
|
self, kw, take_pyo3_options, CrateAttribute, ExtendsAttribute, FreelistAttribute,
|
||||||
ModuleAttribute, NameAttribute, NameLitStr, TextSignatureAttribute,
|
ModuleAttribute, NameAttribute, NameLitStr, TextSignatureAttribute,
|
||||||
};
|
};
|
||||||
use crate::deprecations::{Deprecation, Deprecations};
|
use crate::deprecations::Deprecations;
|
||||||
use crate::konst::{ConstAttributes, ConstSpec};
|
use crate::konst::{ConstAttributes, ConstSpec};
|
||||||
use crate::method::FnSpec;
|
use crate::method::FnSpec;
|
||||||
use crate::pyfunction::text_signature_or_none;
|
use crate::pyfunction::text_signature_or_none;
|
||||||
|
@ -93,8 +93,6 @@ enum PyClassPyO3Option {
|
||||||
TextSignature(TextSignatureAttribute),
|
TextSignature(TextSignatureAttribute),
|
||||||
Unsendable(kw::unsendable),
|
Unsendable(kw::unsendable),
|
||||||
Weakref(kw::weakref),
|
Weakref(kw::weakref),
|
||||||
|
|
||||||
DeprecatedGC(kw::gc),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for PyClassPyO3Option {
|
impl Parse for PyClassPyO3Option {
|
||||||
|
@ -130,8 +128,6 @@ impl Parse for PyClassPyO3Option {
|
||||||
input.parse().map(PyClassPyO3Option::Unsendable)
|
input.parse().map(PyClassPyO3Option::Unsendable)
|
||||||
} else if lookahead.peek(attributes::kw::weakref) {
|
} else if lookahead.peek(attributes::kw::weakref) {
|
||||||
input.parse().map(PyClassPyO3Option::Weakref)
|
input.parse().map(PyClassPyO3Option::Weakref)
|
||||||
} else if lookahead.peek(attributes::kw::gc) {
|
|
||||||
input.parse().map(PyClassPyO3Option::DeprecatedGC)
|
|
||||||
} else {
|
} else {
|
||||||
Err(lookahead.error())
|
Err(lookahead.error())
|
||||||
}
|
}
|
||||||
|
@ -184,10 +180,6 @@ impl PyClassPyO3Options {
|
||||||
PyClassPyO3Option::TextSignature(text_signature) => set_option!(text_signature),
|
PyClassPyO3Option::TextSignature(text_signature) => set_option!(text_signature),
|
||||||
PyClassPyO3Option::Unsendable(unsendable) => set_option!(unsendable),
|
PyClassPyO3Option::Unsendable(unsendable) => set_option!(unsendable),
|
||||||
PyClassPyO3Option::Weakref(weakref) => set_option!(weakref),
|
PyClassPyO3Option::Weakref(weakref) => set_option!(weakref),
|
||||||
|
|
||||||
PyClassPyO3Option::DeprecatedGC(gc) => self
|
|
||||||
.deprecations
|
|
||||||
.push(Deprecation::PyClassGcOption, gc.span()),
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -656,57 +656,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 {
|
impl std::fmt::Debug for PyErr {
|
||||||
|
@ -826,7 +775,7 @@ fn exceptions_must_derive_from_base_exception(py: Python<'_>) -> PyErr {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::PyErrState;
|
use super::PyErrState;
|
||||||
use crate::exceptions;
|
use crate::exceptions;
|
||||||
use crate::{AsPyPointer, PyErr, Python};
|
use crate::{PyErr, Python};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_error() {
|
fn no_error() {
|
||||||
|
@ -972,30 +921,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]
|
#[test]
|
||||||
fn warnings() {
|
fn warnings() {
|
||||||
// Note: although the warning filter is interpreter global, keeping the
|
// Note: although the warning filter is interpreter global, keeping the
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
//! Symbols used to denote deprecated usages of PyO3's proc macros.
|
//! 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(
|
#[deprecated(
|
||||||
since = "0.18.0",
|
since = "0.18.0",
|
||||||
note = "passing arbitrary arguments to `#[pyfunction()]` to specify the signature is being replaced by `#[pyo3(signature)]`"
|
note = "passing arbitrary arguments to `#[pyfunction()]` to specify the signature is being replaced by `#[pyo3(signature)]`"
|
||||||
|
|
|
@ -58,19 +58,6 @@ impl PyType {
|
||||||
{
|
{
|
||||||
self.is_subclass(T::type_object(self.py()))
|
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)]
|
#[cfg(test)]
|
||||||
|
@ -93,15 +80,4 @@ mod tests {
|
||||||
assert!(py.get_type::<PyBool>().is_subclass_of::<PyLong>().unwrap());
|
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());
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
#[pyclass(gc)]
|
|
||||||
struct DeprecatedGc;
|
|
||||||
|
|
||||||
#[pyfunction(_opt = "None", x = "5")]
|
#[pyfunction(_opt = "None", x = "5")]
|
||||||
fn function_with_args(_opt: Option<i32>, _x: i32) {}
|
fn function_with_args(_opt: Option<i32>, _x: i32) {}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
error: use of deprecated constant `pyo3::impl_::deprecations::PYFUNCTION_ARGUMENTS`: passing arbitrary arguments to `#[pyfunction()]` to specify the signature is being replaced by `#[pyo3(signature)]`
|
error: use of deprecated constant `pyo3::impl_::deprecations::PYFUNCTION_ARGUMENTS`: passing arbitrary arguments to `#[pyfunction()]` to specify the signature is being replaced by `#[pyo3(signature)]`
|
||||||
--> tests/ui/deprecations.rs:8:14
|
--> tests/ui/deprecations.rs:5:14
|
||||||
|
|
|
|
||||||
8 | #[pyfunction(_opt = "None", x = "5")]
|
5 | #[pyfunction(_opt = "None", x = "5")]
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
|
@ -10,14 +10,8 @@ note: the lint level is defined here
|
||||||
1 | #![deny(deprecated)]
|
1 | #![deny(deprecated)]
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
error: use of deprecated constant `pyo3::impl_::deprecations::PYCLASS_GC_OPTION`: implement a `__traverse__` `#[pymethod]` instead of using `gc` option
|
|
||||||
--> tests/ui/deprecations.rs:5:11
|
|
||||||
|
|
|
||||||
5 | #[pyclass(gc)]
|
|
||||||
| ^^
|
|
||||||
|
|
||||||
error: use of deprecated constant `pyo3::impl_::deprecations::PYMETHODS_ARGS_ATTRIBUTE`: the `#[args]` attribute for `#[methods]` is being replaced by `#[pyo3(signature)]`
|
error: use of deprecated constant `pyo3::impl_::deprecations::PYMETHODS_ARGS_ATTRIBUTE`: the `#[args]` attribute for `#[methods]` is being replaced by `#[pyo3(signature)]`
|
||||||
--> tests/ui/deprecations.rs:16:12
|
--> tests/ui/deprecations.rs:13:7
|
||||||
|
|
|
|
||||||
16 | #[args(_opt = "None", x = "5")]
|
13 | #[args(_opt = "None", x = "5")]
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: expected one of: `crate`, `dict`, `extends`, `freelist`, `frozen`, `get_all`, `mapping`, `module`, `name`, `sequence`, `set_all`, `subclass`, `text_signature`, `unsendable`, `weakref`, `gc`
|
error: expected one of: `crate`, `dict`, `extends`, `freelist`, `frozen`, `get_all`, `mapping`, `module`, `name`, `sequence`, `set_all`, `subclass`, `text_signature`, `unsendable`, `weakref`
|
||||||
--> tests/ui/invalid_pyclass_args.rs:3:11
|
--> tests/ui/invalid_pyclass_args.rs:3:11
|
||||||
|
|
|
|
||||||
3 | #[pyclass(extend=pyo3::types::PyDict)]
|
3 | #[pyclass(extend=pyo3::types::PyDict)]
|
||||||
|
@ -34,7 +34,7 @@ error: expected string literal
|
||||||
18 | #[pyclass(module = my_module)]
|
18 | #[pyclass(module = my_module)]
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
||||||
error: expected one of: `crate`, `dict`, `extends`, `freelist`, `frozen`, `get_all`, `mapping`, `module`, `name`, `sequence`, `set_all`, `subclass`, `text_signature`, `unsendable`, `weakref`, `gc`
|
error: expected one of: `crate`, `dict`, `extends`, `freelist`, `frozen`, `get_all`, `mapping`, `module`, `name`, `sequence`, `set_all`, `subclass`, `text_signature`, `unsendable`, `weakref`
|
||||||
--> tests/ui/invalid_pyclass_args.rs:21:11
|
--> tests/ui/invalid_pyclass_args.rs:21:11
|
||||||
|
|
|
|
||||||
21 | #[pyclass(weakrev)]
|
21 | #[pyclass(weakrev)]
|
||||||
|
|
Loading…
Reference in New Issue