Skip to content
Merged
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_memoryview.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ def test_tolist(self):
l = m.tolist()
self.assertEqual(l, list(b"abcdef"))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_compare(self):
# memoryviews can compare for equality with other objects
# having the buffer interface.
Expand Down
10 changes: 10 additions & 0 deletions vm/src/builtins/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,16 @@ impl Comparable for PyBytes {
) -> PyResult<PyComparisonValue> {
Ok(if let Some(res) = op.identical_optimization(zelf, other) {
res.into()
} else if other.isinstance(&vm.ctx.types.memoryview_type)
&& op != PyComparisonOp::Eq
&& op != PyComparisonOp::Ne
{
return Err(vm.new_type_error(format!(
"'{}' not supported between instances of '{}' and '{}'",
op.operator_token(),
zelf.class().name,
other.class().name
)));
} else {
zelf.inner.cmp(other, op, vm)
})
Expand Down
5 changes: 4 additions & 1 deletion vm/src/builtins/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,10 @@ impl PyMemoryView {
return Ok(false);
}

let other = try_buffer_from_object(vm, other)?;
let other = match try_buffer_from_object(vm, other) {
Ok(buf) => buf,
Err(_) => return Ok(false),
};

let a_options = &zelf.options;
let b_options = other.get_options();
Expand Down