build: update for Rust 1.49
This commit is contained in:
parent
af50970c89
commit
b1012ebb68
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
|
@ -85,18 +85,18 @@ jobs:
|
|||
run: echo LD_LIBRARY_PATH=${pythonLocation}/lib >> $GITHUB_ENV
|
||||
|
||||
- name: Build docs
|
||||
run: cargo doc --features "num-bigint num-complex" --verbose --target ${{ matrix.platform.rust-target }}
|
||||
run: cargo doc --features "num-bigint num-complex hashbrown" --verbose --target ${{ matrix.platform.rust-target }}
|
||||
|
||||
- name: Build without default features
|
||||
run: cargo build --no-default-features --verbose --target ${{ matrix.platform.rust-target }}
|
||||
|
||||
- name: Build with default features
|
||||
run: cargo build --features "num-bigint num-complex" --verbose --target ${{ matrix.platform.rust-target }}
|
||||
run: cargo build --features "num-bigint num-complex hashbrown" --verbose --target ${{ matrix.platform.rust-target }}
|
||||
|
||||
# Run tests (except on PyPy, because no embedding API).
|
||||
- if: matrix.python-version != 'pypy-3.6'
|
||||
name: Test
|
||||
run: cargo test --features "num-bigint num-complex" --target ${{ matrix.platform.rust-target }}
|
||||
run: cargo test --features "num-bigint num-complex hashbrown" --target ${{ matrix.platform.rust-target }}
|
||||
# Run tests again, but in abi3 mode
|
||||
- if: matrix.python-version != 'pypy-3.6'
|
||||
name: Test (abi3)
|
||||
|
@ -139,7 +139,7 @@ jobs:
|
|||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --features "num-bigint num-complex" --no-fail-fast
|
||||
args: --features "num-bigint num-complex hashbrown" --no-fail-fast
|
||||
env:
|
||||
CARGO_INCREMENTAL: 0
|
||||
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"
|
||||
|
|
|
@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||
- Stop including `Py_TRACE_REFS` config setting automatically if `Py_DEBUG` is set on Python 3.8 and up. [#1334](https://github.com/PyO3/pyo3/pull/1334)
|
||||
- Remove `#[deny(warnings)]` attribute (and instead refuse warnings only in CI). [#1340](https://github.com/PyO3/pyo3/pull/1340)
|
||||
- Fix deprecation warning for missing `__module__` with `#[pyclass]`. [#1343](https://github.com/PyO3/pyo3/pull/1343)
|
||||
- Correct return type of `PyFrozenSet::empty` to `&PyFrozenSet` (was incorrectly `&PySet`). [#1351](https://github.com/PyO3/pyo3/pull/1351)
|
||||
|
||||
## [0.13.0] - 2020-12-22
|
||||
### Packaging
|
||||
|
|
|
@ -58,7 +58,7 @@ pub fn process_functions_in_module(func: &mut syn::ItemFn) -> syn::Result<()> {
|
|||
}
|
||||
|
||||
/// Transforms a rust fn arg parsed with syn into a method::FnArg
|
||||
fn wrap_fn_argument<'a>(cap: &'a syn::PatType) -> syn::Result<method::FnArg<'a>> {
|
||||
fn wrap_fn_argument(cap: &syn::PatType) -> syn::Result<method::FnArg> {
|
||||
let (mutability, by_ref, ident) = match &*cap.pat {
|
||||
syn::Pat::Ident(patid) => (&patid.mutability, &patid.by_ref, &patid.ident),
|
||||
_ => return Err(syn::Error::new_spanned(&cap.pat, "Unsupported argument")),
|
||||
|
|
|
@ -229,7 +229,7 @@ fn parse_descriptors(item: &mut syn::Field) -> syn::Result<Vec<FnType>> {
|
|||
/// To allow multiple #[pymethods]/#[pyproto] block, we define inventory types.
|
||||
fn impl_methods_inventory(cls: &syn::Ident) -> TokenStream {
|
||||
// Try to build a unique type for better error messages
|
||||
let name = format!("Pyo3MethodsInventoryFor{}", cls);
|
||||
let name = format!("Pyo3MethodsInventoryFor{}", cls.unraw());
|
||||
let inventory_cls = syn::Ident::new(&name, Span::call_site());
|
||||
|
||||
quote! {
|
||||
|
|
|
@ -224,7 +224,7 @@ impl ReferencePool {
|
|||
drop(locked);
|
||||
out
|
||||
}};
|
||||
};
|
||||
}
|
||||
|
||||
// Always increase reference counts first - as otherwise objects which have a
|
||||
// nonzero total reference count might be incorrectly dropped by Python during
|
||||
|
|
|
@ -126,10 +126,7 @@ mod complex_conversion {
|
|||
|
||||
impl PyComplex {
|
||||
/// Creates a new Python `PyComplex` object from num_complex::Complex.
|
||||
pub fn from_complex<'py, F: Into<c_double>>(
|
||||
py: Python<'py>,
|
||||
complex: Complex<F>,
|
||||
) -> &'py PyComplex {
|
||||
pub fn from_complex<F: Into<c_double>>(py: Python, complex: Complex<F>) -> &PyComplex {
|
||||
unsafe {
|
||||
let ptr = ffi::PyComplex_FromDoubles(complex.re.into(), complex.im.into());
|
||||
py.from_owned_ptr(ptr)
|
||||
|
|
|
@ -73,7 +73,7 @@ pyobject_native_type!(
|
|||
);
|
||||
|
||||
impl PyDate {
|
||||
pub fn new<'p>(py: Python<'p>, year: i32, month: u8, day: u8) -> PyResult<&'p PyDate> {
|
||||
pub fn new(py: Python, year: i32, month: u8, day: u8) -> PyResult<&PyDate> {
|
||||
unsafe {
|
||||
let ptr = (PyDateTimeAPI.Date_FromDate)(
|
||||
year,
|
||||
|
@ -88,7 +88,7 @@ impl PyDate {
|
|||
/// Construct a `datetime.date` from a POSIX timestamp
|
||||
///
|
||||
/// This is equivalent to `datetime.date.fromtimestamp`
|
||||
pub fn from_timestamp<'p>(py: Python<'p>, timestamp: i64) -> PyResult<&'p PyDate> {
|
||||
pub fn from_timestamp(py: Python, timestamp: i64) -> PyResult<&PyDate> {
|
||||
let time_tuple = PyTuple::new(py, &[timestamp]);
|
||||
|
||||
unsafe {
|
||||
|
@ -336,13 +336,13 @@ pyobject_native_type!(
|
|||
);
|
||||
|
||||
impl PyDelta {
|
||||
pub fn new<'p>(
|
||||
py: Python<'p>,
|
||||
pub fn new(
|
||||
py: Python,
|
||||
days: i32,
|
||||
seconds: i32,
|
||||
microseconds: i32,
|
||||
normalize: bool,
|
||||
) -> PyResult<&'p PyDelta> {
|
||||
) -> PyResult<&PyDelta> {
|
||||
unsafe {
|
||||
let ptr = (PyDateTimeAPI.Delta_FromDelta)(
|
||||
days as c_int,
|
||||
|
|
|
@ -38,7 +38,7 @@ impl PySet {
|
|||
}
|
||||
|
||||
/// Creates a new empty set.
|
||||
pub fn empty<'p>(py: Python<'p>) -> PyResult<&'p PySet> {
|
||||
pub fn empty(py: Python) -> PyResult<&PySet> {
|
||||
unsafe { py.from_owned_ptr_or_err(ffi::PySet_New(ptr::null_mut())) }
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ impl PyFrozenSet {
|
|||
}
|
||||
|
||||
/// Creates a new empty frozen set
|
||||
pub fn empty<'p>(py: Python<'p>) -> PyResult<&'p PySet> {
|
||||
pub fn empty(py: Python) -> PyResult<&PyFrozenSet> {
|
||||
unsafe { py.from_owned_ptr_or_err(ffi::PyFrozenSet_New(ptr::null_mut())) }
|
||||
}
|
||||
|
||||
|
@ -372,16 +372,12 @@ mod hashbrown_hashset_conversion {
|
|||
|
||||
#[test]
|
||||
fn test_extract_hashbrown_hashset() {
|
||||
use std::iter::FromIterator;
|
||||
let gil = Python::acquire_gil();
|
||||
let py = gil.python();
|
||||
|
||||
let set = PySet::new(py, &[1, 2, 3, 4, 5]).unwrap();
|
||||
let hash_set: hashbrown::HashSet<usize> = set.extract().unwrap();
|
||||
assert_eq!(
|
||||
hash_set,
|
||||
hashbrown::HashSet::from_iter([1, 2, 3, 4, 5].iter().copied())
|
||||
);
|
||||
assert_eq!(hash_set, [1, 2, 3, 4, 5].iter().copied().collect());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -402,7 +398,6 @@ mod test {
|
|||
use super::{PyFrozenSet, PySet};
|
||||
use crate::{IntoPy, PyObject, PyTryFrom, Python, ToPyObject};
|
||||
use std::collections::{BTreeSet, HashSet};
|
||||
use std::iter::FromIterator;
|
||||
|
||||
#[test]
|
||||
fn test_set_new() {
|
||||
|
@ -562,10 +557,7 @@ mod test {
|
|||
|
||||
let set = PySet::new(py, &[1, 2, 3, 4, 5]).unwrap();
|
||||
let hash_set: HashSet<usize> = set.extract().unwrap();
|
||||
assert_eq!(
|
||||
hash_set,
|
||||
HashSet::from_iter([1, 2, 3, 4, 5].iter().copied())
|
||||
);
|
||||
assert_eq!(hash_set, [1, 2, 3, 4, 5].iter().copied().collect());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -575,10 +567,7 @@ mod test {
|
|||
|
||||
let set = PySet::new(py, &[1, 2, 3, 4, 5]).unwrap();
|
||||
let hash_set: BTreeSet<usize> = set.extract().unwrap();
|
||||
assert_eq!(
|
||||
hash_set,
|
||||
BTreeSet::from_iter([1, 2, 3, 4, 5].iter().copied())
|
||||
);
|
||||
assert_eq!(hash_set, [1, 2, 3, 4, 5].iter().copied().collect());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -10,26 +10,26 @@ fn test_compile_errors() {
|
|||
t.compile_fail("tests/ui/reject_generics.rs");
|
||||
t.compile_fail("tests/ui/static_ref.rs");
|
||||
|
||||
tests_rust_1_46(&t);
|
||||
tests_rust_1_48(&t);
|
||||
|
||||
#[rustversion::since(1.46)]
|
||||
fn tests_rust_1_46(t: &trybuild::TestCases) {
|
||||
t.compile_fail("tests/ui/invalid_frompy_derive.rs");
|
||||
}
|
||||
#[rustversion::before(1.46)]
|
||||
fn tests_rust_1_46(_t: &trybuild::TestCases) {}
|
||||
tests_rust_1_49(&t);
|
||||
|
||||
#[rustversion::since(1.48)]
|
||||
fn tests_rust_1_48(t: &trybuild::TestCases) {
|
||||
t.compile_fail("tests/ui/invalid_pymethod_receiver.rs");
|
||||
t.compile_fail("tests/ui/invalid_result_conversion.rs");
|
||||
t.compile_fail("tests/ui/missing_clone.rs");
|
||||
t.compile_fail("tests/ui/wrong_aspyref_lifetimes.rs");
|
||||
}
|
||||
#[rustversion::before(1.48)]
|
||||
fn tests_rust_1_48(_t: &trybuild::TestCases) {}
|
||||
|
||||
#[rustversion::since(1.49)]
|
||||
fn tests_rust_1_49(t: &trybuild::TestCases) {
|
||||
t.compile_fail("tests/ui/invalid_frompy_derive.rs");
|
||||
t.compile_fail("tests/ui/invalid_pymethod_receiver.rs");
|
||||
|
||||
#[cfg(Py_LIMITED_API)]
|
||||
t.compile_fail("tests/ui/abi3_nativetype_inheritance.rs");
|
||||
}
|
||||
#[rustversion::before(1.48)]
|
||||
fn tests_rust_1_48(_t: &trybuild::TestCases) {}
|
||||
#[rustversion::before(1.49)]
|
||||
fn tests_rust_1_49(_t: &trybuild::TestCases) {}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ fn test_custom_error() {
|
|||
|
||||
#[test]
|
||||
fn test_exception_nosegfault() {
|
||||
use std::{net::TcpListener, panic};
|
||||
use std::net::TcpListener;
|
||||
fn io_err() -> PyResult<()> {
|
||||
TcpListener::bind("no:address")?;
|
||||
Ok(())
|
||||
|
|
|
@ -7,7 +7,7 @@ error[E0277]: the trait bound `PyDictObject: PySizedLayout<PyDict>` is not satis
|
|||
::: $WORKSPACE/src/type_object.rs
|
||||
|
|
||||
| type BaseLayout: PySizedLayout<Self::BaseType>;
|
||||
| ----------------------------- required by this bound in `PyTypeInfo`
|
||||
| ----------------------------- required by this bound in `pyo3::PyTypeInfo::BaseLayout`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `PySizedLayout<PyDict>` for `PyCellBase<PyDict>`
|
||||
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
|
|
@ -142,7 +142,7 @@ error: Annotating error messages for structs is not supported. Remove the annota
|
|||
--> $DIR/invalid_frompy_derive.rs:129:1
|
||||
|
|
||||
129 | #[pyo3(annotation = "should not work")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^
|
||||
|
||||
error: Expected string literal.
|
||||
--> $DIR/invalid_frompy_derive.rs:136:25
|
||||
|
|
|
@ -12,3 +12,4 @@ error[E0277]: the trait bound `i32: From<&PyCell<MyClass>>` is not satisfied
|
|||
and 2 others
|
||||
= note: required because of the requirements on the impl of `Into<i32>` for `&PyCell<MyClass>`
|
||||
= note: required because of the requirements on the impl of `TryFrom<&PyCell<MyClass>>` for `i32`
|
||||
= note: required by `std::convert::TryFrom::try_from`
|
||||
|
|
Loading…
Reference in a new issue