sdbus++: catch elements with non-string names
The Python YAML parser turns certain keywords into non-string types,
such as 'On' -> True, 'Off' -> False. If these aren't identified,
interfaces can be defined for which names become the
string-representation of these non-string names. This is especially
problematic for 'On'/'Off' becoming 'True'/'False'.
Catch this condition and report an assertion.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I126056e3eac9f97ebd7b095962da2b765046b532
diff --git a/tools/sdbusplus/namedelement.py b/tools/sdbusplus/namedelement.py
index 8e02a7a..a1d617f 100644
--- a/tools/sdbusplus/namedelement.py
+++ b/tools/sdbusplus/namedelement.py
@@ -8,6 +8,12 @@
self.name = kwargs.pop('name', "unnamed")
self.description = kwargs.pop('description', "")
+ if not isinstance(self.name, str):
+ raise AttributeError(
+ "Element interpreted by YAML parser as non-string; likely "
+ "missing quotes around original name."
+ )
+
def __getattribute__(self, name):
lam = {'CamelCase': lambda: inflection.camelize(self.name),
'camelCase': lambda: NamedElement.lower_camel_case(self.name),