Skip to contentSkip to conversation

data_smart: Don't add None to ExpansionError varlist

PATCH New Richard Purdie 1 participant 1 message Sep 20, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 data_smart: Don't add None to ExpansionError varlist

If a "None" value gets into the varlist, it doesn't display properly. Ensure we don't add one to have the exception display properly.

---
 lib/bb/data_smart.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
lib/bb/data_smart.py +3 -2
index ec7bb561cc..8d235da121 100644
@@ -151,7 +151,7 @@ class ExpansionError(Exception):
         self.expression = expression
         self.variablename = varname
         self.exception = exception
-        self.varlist = [varname or expression]
+        self.varlist = [varname or expression or ""]
         if varname:
             if expression:
                 self.msg = "Failure expanding variable %s, expression was %s which triggered exception %s: %s" % (varname, expression, type(exception).__name__, exception)
@@ -163,7 +163,8 @@ class ExpansionError(Exception):
         self.args = (varname, expression, exception)
 
     def addVar(self, varname):
-        self.varlist.append(varname)
+        if varname:
+            self.varlist.append(varname)
 
     def __str__(self):
         chain = "\nThe variable dependency chain for the failure is: " + " -> ".join(self.varlist)
Signature · 1 line
2.32.0