Skip to content

solved test case error for test_dictviews.py from object.rs #4779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Lib/test/test_dictviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions vm/src/protocol/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,13 @@ impl PyObject {
opid: PyComparisonOp,
vm: &VirtualMachine,
) -> PyResult<bool> {
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),
Expand Down
Loading