forked from Rust-related/RustPython
Merge pull request #1463 from lazylife7157/memoryview_hash
Fix #1394 Memoryview hash problem
This commit is contained in:
@@ -4,3 +4,5 @@ a = memoryview(obj)
|
||||
assert a.obj == obj
|
||||
|
||||
assert a[2:3] == b"c"
|
||||
|
||||
assert hash(obj) == hash(a)
|
||||
|
||||
@@ -34,6 +34,11 @@ impl PyMemoryView {
|
||||
self.obj_ref.clone()
|
||||
}
|
||||
|
||||
#[pymethod(name = "__hash__")]
|
||||
fn hash(&self, vm: &VirtualMachine) -> PyResult {
|
||||
vm.call_method(&self.obj_ref, "__hash__", vec![])
|
||||
}
|
||||
|
||||
#[pymethod(name = "__getitem__")]
|
||||
fn getitem(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult {
|
||||
vm.call_method(&self.obj_ref, "__getitem__", vec![needle])
|
||||
|
||||
Reference in New Issue
Block a user