adafruit/Adafruit_CircuitPython_Display_Text

Label init with max_glyphs instead of text value is broken

flavio-fernandes opened this issue · 0 comments

When Label class is initialized with size instead of text.
The split function is attempted in None object instead of an empty string.
That will cause this:

      File "/lib/adafruit_display_text/label.py", line 84, in __init__
      AttributeError: 'NoneType' object has no attribute 'split'

This is code with this issue (look at lines 78 ans 84):

text = kwargs.get("text", None)
if not max_glyphs and not text:
raise RuntimeError("Please provide a max size, or initial text")
self._tab_replacement = kwargs.get("tab_replacement", (4, " "))
self._tab_text = self._tab_replacement[1] * self._tab_replacement[0]
text = self._tab_text.join(text.split("\t"))

To reproduce, simply create a Label like this:

import terminalio
from adafruit_display_text import label

text_area = label.Label(terminalio.FONT, max_glyphs=10)

This used to work, so I suspect it is a regression introduced here:
2b4f1ad