Workchains: Raise if if_/while_ predicate does not return boolean#259
Merged
sphuber merged 1 commit intosupport/0.21.xfrom Mar 9, 2023
Merged
Conversation
93434b8 to
e61637e
Compare
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## support/0.21.x #259 +/- ##
===============================================
Coverage 90.74% 90.74%
===============================================
Files 21 21
Lines 2967 2967
===============================================
Hits 2692 2692
Misses 275 275 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
e61637e to
bda08b3
Compare
sphuber
added a commit
that referenced
this pull request
Mar 9, 2023
…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
unkcpz
pushed a commit
to unkcpz/plumpy
that referenced
this pull request
Dec 14, 2024
…iidateam#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
agoscinski
pushed a commit
to agoscinski/plumpy
that referenced
this pull request
Apr 13, 2026
…iidateam#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
agoscinski
pushed a commit
that referenced
this pull request
Apr 13, 2026
…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
agoscinski
pushed a commit
that referenced
this pull request
Apr 13, 2026
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #258
The
if_andwhile_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_truemethod is updated to explicitly check the type of the value returned by the predicate. If anything but a boolean is returned, aTypeErroris raised.