fix(probes): guard badchars ASCII selection against max_ascii_variants=1 - #2012
Open
manunicholasjacob wants to merge 1 commit into
Open
fix(probes): guard badchars ASCII selection against max_ascii_variants=1#2012manunicholasjacob wants to merge 1 commit into
manunicholasjacob wants to merge 1 commit into
Conversation
_select_ascii divided by (limit - 1) after guards that let limit == 1 through, so the user-settable max_ascii_variants=1 raised ZeroDivisionError at probe construction. The sibling _select_positions in the same class already special-cases cap == 1; mirror that. Signed-off-by: manunicholasjacob <manunicholasjacob@gmail.com>
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.
What this changes
BadCharacters._select_ascii()divides bylimit - 1:limit == 1passes both guards, so the division raisesZeroDivisionError.max_ascii_variantsis configurable viaDEFAULT_PARAMS, so setting it to 1prevents the probe from constructing.
_select_positions()in the same class already handles the equivalent case:This adds the matching guard to
_select_ascii().Reproduction
fails at probe construction with
integer division or modulo by zero. Valuesof 2 and above work as expected.
Testing
Adds
tests/probes/test_probes_badchars.pycovering limits 1, 2 and 3. Thelimit-1 case fails on
mainand passes with this change.