Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workchains: Raise if
if_/while_
predicate does not return boolean (#…
…259) The `if_` and `while_` conditionals are constructed with a predicate. The interface expects the predicate to be a callable that returns a boolean, which if true, the body of the conditional is entered. The problem is that the type of the value returned by the predicate was not explicitly checked, and any value that would evaluate as truthy would be accepted. This could potentially lead to unexpected behavior, such as an infinite loop for the `while_` construct. Here the `_Conditional.is_true` method is updated to explicitly check the type of the value returned by the predicate. If anything but a boolean is returned, a `TypeError` is raised. Cherry-pick: 800bcf1
- Loading branch information