Repository navigation
Fix #241, Keep array_size as string during validation in CHeaderParser - #271
Open
reginaldalfret wants to merge 1 commit into
Open
reginaldalfret wants to merge 1 commit into
reginaldalfret wants to merge 1 commit into
Conversation
…arser Avoid casting array_size to int within the validation loop in CHeaderParser.py, which caused an AttributeError on isdigit() when the user provided an out-of-bounds input. Also add prompt_array_size helper function and unit tests.
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.
Summary
Fix an
AttributeError: 'int' object has no attribute 'isdigit'when entering array sizes for command parameters inCHeaderParser.py.Motivation
When parsing C header files for command parameters,
CHeaderParser.pyprompts the user for array sizes that could not be automatically resolved. In the previous implementation, user input was cast tointwithin the validation loop (array_size = int(input(...))). When a user entered an out-of-bounds number or if re-prompting was needed, the subsequent loop iteration calledarray_size.isdigit()on an integer, causing a runtimeAttributeError.Resolves #241.
Implementation
prompt_array_sizethat validates whether an array size string consists of digits and represents an integer inrange(129).array_sizeas a string throughout the prompt loop soisdigit()remains valid across multiple user attempts.param_lens[-1]with the validated value and appended tostring_lens.Subsystems/cmdGui/test_cheaderparser.pytesting valid inputs, boundary conditions (0, 128), out-of-bounds inputs, and non-numeric strings.Testing
Test command:
python -m unittest test_cheaderparser.pyOutput:
` ext
.....
Ran 5 tests in 0.000s
OK
`
Compatibility and impact
No breaking changes or impact on downstream consumers. Preserves ground system parameter pickle formats.
Related issue
Closes #241