From df23a527770cf3ad63f81cc1b6c7e6cd20f2e428 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Thu, 31 Dec 2020 15:46:54 +0000 Subject: [PATCH] build: update for Rust 1.49 --- CHANGELOG.md | 1 + pyo3-macros-backend/src/module.rs | 2 +- src/gil.rs | 2 +- src/types/datetime.rs | 10 +++++----- src/types/set.rs | 4 ++-- tests/test_compile_error.rs | 18 +++++++++--------- tests/ui/invalid_frompy_derive.stderr | 2 +- tests/ui/invalid_pymethod_receiver.stderr | 1 + 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6ab595bb80..7c8254929a0 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 a09a2ccbd13..12463dd1993 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/src/gil.rs b/src/gil.rs index 135881b3ef5..183af48ec0b 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/datetime.rs b/src/types/datetime.rs index 89dbeb201ae..97d8aa0c1a0 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 5593490afd8..1342725107f 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())) } } diff --git a/tests/test_compile_error.rs b/tests/test_compile_error.rs index 59f4a03f89c..1051f0445cd 100644 --- a/tests/test_compile_error.rs +++ b/tests/test_compile_error.rs @@ -10,19 +10,11 @@ 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"); @@ -32,4 +24,12 @@ fn test_compile_errors() { } #[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"); + } + #[rustversion::before(1.49)] + fn tests_rust_1_49(_t: &trybuild::TestCases) {} } diff --git a/tests/ui/invalid_frompy_derive.stderr b/tests/ui/invalid_frompy_derive.stderr index 4eaf1218586..cb5424466af 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 e43a08ed209..d6dc0ac6254 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`