(zelf: &PyObject, vm: &VirtualMachine)
| 484 | } |
| 485 | |
| 486 | fn hash_wrapper(zelf: &PyObject, vm: &VirtualMachine) -> PyResult<PyHash> { |
| 487 | let hash_obj = vm.call_special_method(zelf, identifier!(vm, __hash__), ())?; |
| 488 | let py_int = hash_obj |
| 489 | .downcast_ref::<PyInt>() |
| 490 | .ok_or_else(|| vm.new_type_error("__hash__ method should return an integer"))?; |
| 491 | let big_int = py_int.as_bigint(); |
| 492 | let hash = big_int |
| 493 | .to_i64() |
| 494 | .map(fix_sentinel) |
| 495 | .unwrap_or_else(|| hash_bigint(big_int)); |
| 496 | Ok(hash) |
| 497 | } |
| 498 | |
| 499 | /// Marks a type as unhashable. Similar to PyObject_HashNotImplemented in CPython |
| 500 | pub fn hash_not_implemented(zelf: &PyObject, vm: &VirtualMachine) -> PyResult<PyHash> { |
nothing calls this directly
no test coverage detected