Skip to content

Commit

Permalink
build: update for Rust 1.49
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Dec 31, 2020
1 parent af50970 commit df23a52
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyo3-macros-backend/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
Expand Down
2 changes: 1 addition & 1 deletion src/gil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/types/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/types/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())) }
}

Expand Down Expand Up @@ -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())) }
}

Expand Down
18 changes: 9 additions & 9 deletions tests/test_compile_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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) {}
}
2 changes: 1 addition & 1 deletion tests/ui/invalid_frompy_derive.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/ui/invalid_pymethod_receiver.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`

0 comments on commit df23a52

Please sign in to comment.