diff --git a/pyo3-macros-backend/src/pymethod.rs b/pyo3-macros-backend/src/pymethod.rs index f0fced41184..d49898ddb31 100644 --- a/pyo3-macros-backend/src/pymethod.rs +++ b/pyo3-macros-backend/src/pymethod.rs @@ -695,12 +695,14 @@ struct SlotDef { return_mode: Option, } +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, diff --git a/src/class/basic.rs b/src/class/basic.rs index 602096c53ff..1e34d493e5d 100644 --- a/src/class/basic.rs +++ b/src/class/basic.rs @@ -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 diff --git a/tests/test_proto_methods.rs b/tests/test_proto_methods.rs index 8e4051976ed..1cfafefdedb 100644 --- a/tests/test_proto_methods.rs +++ b/tests/test_proto_methods.rs @@ -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}; @@ -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 } @@ -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| {