diff --git a/Lib/test/test_dictviews.py b/Lib/test/test_dictviews.py index 172b98aa68..6e7140314f 100644 --- a/Lib/test/test_dictviews.py +++ b/Lib/test/test_dictviews.py @@ -292,8 +292,6 @@ def test_copy(self): self.assertRaises(TypeError, copy.copy, d.values()) self.assertRaises(TypeError, copy.copy, d.items()) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_compare_error(self): class Exc(Exception): pass diff --git a/vm/src/protocol/object.rs b/vm/src/protocol/object.rs index 4cdcb68257..3d81c0d506 100644 --- a/vm/src/protocol/object.rs +++ b/vm/src/protocol/object.rs @@ -333,6 +333,13 @@ impl PyObject { opid: PyComparisonOp, vm: &VirtualMachine, ) -> PyResult { + if self.is(other) { + if opid == PyComparisonOp::Eq { + return Ok(true); + } else if opid == PyComparisonOp::Ne { + return Ok(false); + } + } match self._cmp(other, opid, vm)? { Either::A(obj) => obj.try_to_bool(vm), Either::B(other) => Ok(other),