_PyEval_SpecialMethodCanSuggest
(
obj: &PyObjectRef,
oparg: SpecialMethod,
vm: &VirtualMachine,
)
| 9623 | |
| 9624 | /// _PyEval_SpecialMethodCanSuggest |
| 9625 | fn special_method_can_suggest( |
| 9626 | obj: &PyObjectRef, |
| 9627 | oparg: SpecialMethod, |
| 9628 | vm: &VirtualMachine, |
| 9629 | ) -> PyResult<bool> { |
| 9630 | Ok(match oparg { |
| 9631 | SpecialMethod::Enter | SpecialMethod::Exit => { |
| 9632 | vm.get_special_method(obj, get_special_method_name(SpecialMethod::AEnter, vm))? |
| 9633 | .is_some() |
| 9634 | && vm |
| 9635 | .get_special_method(obj, get_special_method_name(SpecialMethod::AExit, vm))? |
| 9636 | .is_some() |
| 9637 | } |
| 9638 | SpecialMethod::AEnter | SpecialMethod::AExit => { |
| 9639 | vm.get_special_method(obj, get_special_method_name(SpecialMethod::Enter, vm))? |
| 9640 | .is_some() |
| 9641 | && vm |
| 9642 | .get_special_method(obj, get_special_method_name(SpecialMethod::Exit, vm))? |
| 9643 | .is_some() |
| 9644 | } |
| 9645 | }) |
| 9646 | } |
| 9647 | |
| 9648 | fn get_special_method_name(oparg: SpecialMethod, vm: &VirtualMachine) -> &'static PyStrInterned { |
| 9649 | match oparg { |
no test coverage detected