String index out of range when converting a line #17
Labels
bug
Something isn't working
good first issue
Good for newcomers
help wanted
Extra attention is needed
Describe the bug
When converting a line with
vestaboard.Formatter().convertLine()
that contains text and bracket-encoded characters exactly the length of the line (22 characters), conversion fails with the messageIndexError: string index out of range
.To Reproduce
Steps to reproduce the behavior:
Expected behavior
The
convertLine()
method should convert any input string containing valid characters as long as the string has a length of <= 22. Valid character codes can be found on Vestaboard's Character Code reference page..convertLine()
should return a list of integers once conversion is complete.Additional context
This bug seems to only affect strings that end with bracket-encoded characters of a single digit. The below line works, for example, and does not throw an error:
fm.convertLine('{0}{0}{0}{0}{0}{0}{63}{64}{65}{66}{67}{68}{69}{0}{0}{0}{0}{0}{0}THU')
Possibility the issue is actually with bracket-encoded characters at the end of the input string, where searching for the closing (matching) bracket would cause an attempted string access at an index which is beyond the length of the string.
Current Workaround
Replace bracket-encoded characters with their actual values - for example, use spaces instead of
{0}
. Note that when using thevestaboard.Board().post()
method, this may not work as Vestaboard's endpoint strips out leading and trailing whitespace when using the.post()
method.Check file
vestaboard/formatter.py
on line 79 - I believe this is where the error is throwing. There is a check for a closing bracket 2 characters over (a two-digit character code), but when the string ends with a one-digit code, that could cause the error as the formatter will be attempting to access the string at an index beyond the length of the string.The text was updated successfully, but these errors were encountered: