diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5905894a..9339677f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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" diff --git a/CHANGELOG.md b/CHANGELOG.md index a6ab595b..7c825492 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/pyo3-macros-backend/src/module.rs b/pyo3-macros-backend/src/module.rs index a09a2ccb..12463dd1 100644 --- a/pyo3-macros-backend/src/module.rs +++ b/pyo3-macros-backend/src/module.rs @@ -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> { +fn wrap_fn_argument(cap: &syn::PatType) -> syn::Result { 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")), diff --git a/pyo3-macros-backend/src/pyclass.rs b/pyo3-macros-backend/src/pyclass.rs index 77f76eb4..28a27e70 100644 --- a/pyo3-macros-backend/src/pyclass.rs +++ b/pyo3-macros-backend/src/pyclass.rs @@ -229,7 +229,7 @@ fn parse_descriptors(item: &mut syn::Field) -> syn::Result> { /// 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! { diff --git a/src/gil.rs b/src/gil.rs index 135881b3..183af48e 100644 --- a/src/gil.rs +++ b/src/gil.rs @@ -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 diff --git a/src/types/complex.rs b/src/types/complex.rs index 69d92c17..19ad2771 100644 --- a/src/types/complex.rs +++ b/src/types/complex.rs @@ -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>( - py: Python<'py>, - complex: Complex, - ) -> &'py PyComplex { + pub fn from_complex>(py: Python, complex: Complex) -> &PyComplex { unsafe { let ptr = ffi::PyComplex_FromDoubles(complex.re.into(), complex.im.into()); py.from_owned_ptr(ptr) diff --git a/src/types/datetime.rs b/src/types/datetime.rs index 89dbeb20..97d8aa0c 100644 --- a/src/types/datetime.rs +++ b/src/types/datetime.rs @@ -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, diff --git a/src/types/set.rs b/src/types/set.rs index 5593490a..3989edfb 100644 --- a/src/types/set.rs +++ b/src/types/set.rs @@ -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 = 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 = 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 = 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] diff --git a/tests/test_compile_error.rs b/tests/test_compile_error.rs index 59f4a03f..99f52e71 100644 --- a/tests/test_compile_error.rs +++ b/tests/test_compile_error.rs @@ -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) {} } diff --git a/tests/test_exceptions.rs b/tests/test_exceptions.rs index 5d4a9a65..710b1705 100644 --- a/tests/test_exceptions.rs +++ b/tests/test_exceptions.rs @@ -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(()) diff --git a/tests/ui/abi3_nativetype_inheritance.stderr b/tests/ui/abi3_nativetype_inheritance.stderr index 54cacd50..cf825281 100644 --- a/tests/ui/abi3_nativetype_inheritance.stderr +++ b/tests/ui/abi3_nativetype_inheritance.stderr @@ -7,7 +7,7 @@ error[E0277]: the trait bound `PyDictObject: PySizedLayout` is not satis ::: $WORKSPACE/src/type_object.rs | | type BaseLayout: PySizedLayout; - | ----------------------------- 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` for `PyCellBase` = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/invalid_frompy_derive.stderr b/tests/ui/invalid_frompy_derive.stderr index 4eaf1218..cb542446 100644 --- a/tests/ui/invalid_frompy_derive.stderr +++ b/tests/ui/invalid_frompy_derive.stderr @@ -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 diff --git a/tests/ui/invalid_pymethod_receiver.stderr b/tests/ui/invalid_pymethod_receiver.stderr index e43a08ed..d6dc0ac6 100644 --- a/tests/ui/invalid_pymethod_receiver.stderr +++ b/tests/ui/invalid_pymethod_receiver.stderr @@ -12,3 +12,4 @@ error[E0277]: the trait bound `i32: From<&PyCell>` is not satisfied and 2 others = note: required because of the requirements on the impl of `Into` for `&PyCell` = note: required because of the requirements on the impl of `TryFrom<&PyCell>` for `i32` + = note: required by `std::convert::TryFrom::try_from`