Merge pull request #1463 from lazylife7157/memoryview_hash

Fix #1394 Memoryview hash problem
This commit is contained in:
Windel Bouwman
2019-10-04 10:55:18 +02:00
committed by GitHub
2 changed files with 7 additions and 0 deletions

View File

@@ -4,3 +4,5 @@ a = memoryview(obj)
assert a.obj == obj
assert a[2:3] == b"c"
assert hash(obj) == hash(a)

View File

@@ -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])