Skip to content
Merged
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions vm/src/protocol/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,11 @@ impl PyObject {
}

pub fn hash(&self, vm: &VirtualMachine) -> PyResult<PyHash> {
// __hash__ function in str cannot be overwritten
if let Some(pystr) = self.downcast_ref_if_exact::<PyStr>(vm) {
return Ok(pystr.hash(vm));
}

let hash = self.get_class_attr(identifier!(vm, __hash__)).unwrap();
if vm.is_none(&hash) {
return Err(vm.new_exception_msg(
Expand Down
Loading