forked from Rust-related/RustPython
tp_cmp -> tp_richcompare
this was the last typeslot with mismatching name
This commit is contained in:
@@ -40,7 +40,7 @@ impl PyBaseObject {
|
||||
}
|
||||
|
||||
#[pyslot]
|
||||
fn tp_cmp(
|
||||
fn tp_richcompare(
|
||||
zelf: &PyObjectRef,
|
||||
other: &PyObjectRef,
|
||||
op: PyComparisonOp,
|
||||
@@ -67,7 +67,7 @@ impl PyBaseObject {
|
||||
PyComparisonOp::Ne => {
|
||||
let cmp = zelf
|
||||
.class()
|
||||
.mro_find_map(|cls| cls.slots.cmp.load())
|
||||
.mro_find_map(|cls| cls.slots.richcompare.load())
|
||||
.unwrap();
|
||||
let value = match cmp(zelf, other, PyComparisonOp::Eq, vm)? {
|
||||
Either::A(obj) => PyArithmaticValue::from_object(vm, obj)
|
||||
|
||||
@@ -193,11 +193,11 @@ impl PyType {
|
||||
update_slot!(del, func);
|
||||
}
|
||||
"__eq__" | "__ne__" | "__le__" | "__lt__" | "__ge__" | "__gt__" => {
|
||||
let func: slots::CmpFunc = |zelf, other, op, vm| {
|
||||
let func: slots::RichCompareFunc = |zelf, other, op, vm| {
|
||||
vm.call_special_method(zelf.clone(), op.method_name(), (other.clone(),))
|
||||
.map(Either::A)
|
||||
} as _;
|
||||
update_slot!(cmp, func);
|
||||
update_slot!(richcompare, func);
|
||||
}
|
||||
"__getattribute__" => {
|
||||
let func: slots::GetattroFunc =
|
||||
|
||||
@@ -52,7 +52,7 @@ pub(crate) type DescrGetFunc =
|
||||
pub(crate) type DescrSetFunc =
|
||||
fn(PyObjectRef, PyObjectRef, Option<PyObjectRef>, &VirtualMachine) -> PyResult<()>;
|
||||
pub(crate) type HashFunc = fn(&PyObjectRef, &VirtualMachine) -> PyResult<PyHash>;
|
||||
pub(crate) type CmpFunc = fn(
|
||||
pub(crate) type RichCompareFunc = fn(
|
||||
&PyObjectRef,
|
||||
&PyObjectRef,
|
||||
PyComparisonOp,
|
||||
@@ -89,7 +89,7 @@ pub struct PyTypeSlots {
|
||||
|
||||
// Assigned meaning in release 2.1
|
||||
// rich comparisons
|
||||
pub cmp: AtomicCell<Option<CmpFunc>>,
|
||||
pub richcompare: AtomicCell<Option<RichCompareFunc>>,
|
||||
|
||||
// Iterators
|
||||
pub iter: AtomicCell<Option<IterFunc>>,
|
||||
@@ -268,7 +268,7 @@ where
|
||||
#[pyimpl]
|
||||
pub trait Comparable: PyValue {
|
||||
#[pyslot]
|
||||
fn tp_cmp(
|
||||
fn tp_richcompare(
|
||||
zelf: &PyObjectRef,
|
||||
other: &PyObjectRef,
|
||||
op: PyComparisonOp,
|
||||
|
||||
@@ -1654,7 +1654,7 @@ impl VirtualMachine {
|
||||
let call_cmp = |obj: &PyObjectRef, other, op| {
|
||||
let cmp = obj
|
||||
.class()
|
||||
.mro_find_map(|cls| cls.slots.cmp.load())
|
||||
.mro_find_map(|cls| cls.slots.richcompare.load())
|
||||
.unwrap();
|
||||
Ok(match cmp(obj, other, op, self)? {
|
||||
Either::A(obj) => PyArithmaticValue::from_object(self, obj).map(Either::A),
|
||||
|
||||
Reference in New Issue
Block a user