Skip to content

Fix #241, Keep array_size as string during validation in CHeaderParser - #271

Open
reginaldalfret wants to merge 1 commit into
nasa:devfrom
reginaldalfret:fix/241-cheaderparser-array-size-isdigit
Open

reginaldalfret wants to merge 1 commit into
nasa:devfrom
reginaldalfret:fix/241-cheaderparser-array-size-isdigit

Conversation

@reginaldalfret

@reginaldalfret reginaldalfret commented Oct 16, 2026 •

Copy link
Copy Markdown

Summary

Fix an AttributeError: 'int' object has no attribute 'isdigit' when entering array sizes for command parameters in CHeaderParser.py.

Motivation

When parsing C header files for command parameters, CHeaderParser.py prompts the user for array sizes that could not be automatically resolved. In the previous implementation, user input was cast to int within 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 called array_size.isdigit() on an integer, causing a runtime AttributeError.

Resolves #241.

Implementation

  • Created a dedicated helper function prompt_array_size that validates whether an array size string consists of digits and represents an integer in range(129).
  • Kept array_size as a string throughout the prompt loop so isdigit() remains valid across multiple user attempts.
  • Updated param_lens[-1] with the validated value and appended to string_lens.
  • Added unit tests in Subsystems/cmdGui/test_cheaderparser.py testing valid inputs, boundary conditions (0, 128), out-of-bounds inputs, and non-numeric strings.

Testing

  • Targeted regression test
  • Relevant unit tests

Test command:
python -m unittest test_cheaderparser.py

Output:
` 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

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: 'int' object has no attribute 'isdigit'

1 participant