Update rule comparison operators to work with mixed operator types (bytes and strings) #4831
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.
This pull request updates all the rule criteria comparison operators which also work with strings (a lot of operators work on multiple types), to try to convert both operators to unicode / string type if either or both of them are of a type bytes.
In ideal world, user would always know a type of each input, but that's rarely the case. Depending on how data is retrieved or defined (e.g. webhook body, etc.) the actual type might be bytes or a string / unicode.
This means that pretty much the only option we are left with for rule comparison operators to work as expected when mixed types come into play is to try to convert both of the operators to the same common type aka unicode / string.
NOTE: This issue / problem only affects Python 3.x deployments.