Skip to content

Commit

Permalink
pymethods: fix support for MSRV
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Sep 18, 2021
1 parent 592c98c commit 179b5d1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
4 changes: 3 additions & 1 deletion pyo3-macros-backend/src/pymethod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,12 +695,14 @@ struct SlotDef {
return_mode: Option<ReturnMode>,
}

const NO_ARGUMENTS: &[Ty] = &[];

impl SlotDef {
const fn new(slot: &'static str, func_ty: &'static str) -> Self {
SlotDef {
slot: StaticIdent(slot),
func_ty: StaticIdent(func_ty),
arguments: &[],
arguments: NO_ARGUMENTS,
ret_ty: Ty::Object,
before_call_method: None,
extract_error_mode: ExtractErrorMode::Raise,
Expand Down
11 changes: 0 additions & 11 deletions src/class/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,6 @@ impl CompareOp {
_ => None,
}
}

pub fn matches_ordering(self, ordering: std::cmp::Ordering) -> bool {
match self {
CompareOp::Lt => ordering.is_lt(),
CompareOp::Le => ordering.is_le(),
CompareOp::Eq => ordering.is_eq(),
CompareOp::Ne => ordering.is_ne(),
CompareOp::Gt => ordering.is_gt(),
CompareOp::Ge => ordering.is_ge(),
}
}
}

/// Basic Python class customization
Expand Down
18 changes: 1 addition & 17 deletions tests/test_proto_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use pyo3::exceptions::PyValueError;
use pyo3::types::{PySlice, PyType};
use pyo3::{basic::CompareOp, exceptions::PyAttributeError, prelude::*};
use pyo3::{exceptions::PyAttributeError, prelude::*};
use pyo3::{ffi, py_run, AsPyPointer, PyCell};
use std::{isize, iter};

Expand Down Expand Up @@ -56,10 +56,6 @@ impl ExampleClass {
i64_value as u64
}

fn __richcmp__(&self, other: &Self, op: CompareOp) -> bool {
op.matches_ordering(self.value.cmp(&other.value))
}

fn __bool__(&self) -> bool {
self.value != 0
}
Expand Down Expand Up @@ -156,18 +152,6 @@ fn test_hash() {
})
}

#[test]
fn test_richcmp() {
Python::with_gil(|py| {
let example_py = make_example(py);
assert!(example_py
.rich_compare(example_py, CompareOp::Eq)
.unwrap()
.is_true()
.unwrap());
})
}

#[test]
fn test_bool() {
Python::with_gil(|py| {
Expand Down

0 comments on commit 179b5d1

Please sign in to comment.