From d337b298e92dc75e7b0722f5bd4e33622ca18c0d Mon Sep 17 00:00:00 2001 From: Flavio Fernandes Date: Sat, 13 Mar 2021 10:06:13 -0500 Subject: [PATCH] label.py: Fix Label when initial text is not provided This change addresses cases when Label class is initialized with max_glyphs instead of text. In such cases, the split function is attempted on None object instead of an empty string: File "/lib/adafruit_display_text/label.py", line 84, in __init__ AttributeError: 'NoneType' object has no attribute 'split' Fixes: https://github.com/adafruit/Adafruit_CircuitPython_Display_Text/issues/141 --- adafruit_display_text/label.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_display_text/label.py b/adafruit_display_text/label.py index dadc7f0..ea78f4f 100755 --- a/adafruit_display_text/label.py +++ b/adafruit_display_text/label.py @@ -75,7 +75,7 @@ def __init__(self, font, **kwargs): super().__init__(font, **kwargs) max_glyphs = kwargs.get("max_glyphs", None) - text = kwargs.get("text", None) + text = kwargs.get("text", "") if not max_glyphs and not text: raise RuntimeError("Please provide a max size, or initial text")