update _display_value to handle None case

This commit is contained in:
eve
2025-03-28 14:51:31 +00:00
parent ec9e738334
commit fe6d57554b
+33 -16
View File
@@ -587,26 +587,43 @@ class Volshell(interfaces.plugins.PluginInterface):
def _display_value(self, value: Any) -> str:
try:
# if value is a BaseAbsentValue they display N/A
if isinstance(value, interfaces.renderers.BaseAbsentValue):
return "N/A"
elif isinstance(value, objects.Pointer):
# show pointers in hex to match output for struct addrs
# highlight null or unreadable pointers
if value == 0:
suffix = " (null pointer)"
elif not value.is_readable():
suffix = " (unreadable pointer)"
else:
suffix = ""
return f"{hex(value)}{suffix}"
elif isinstance(value, objects.PrimitiveObject):
return repr(value)
elif isinstance(value, objects.Array):
return repr([self._display_value(val) for val in value])
else:
return hex(value.vol.offset)
# volobject branch
if isinstance(
value,
Union[
interfaces.objects.ObjectInterface, interfaces.objects.Template
],
):
if isinstance(value, objects.Pointer):
# show pointers in hex to match output for struct addrs
# highlight null or unreadable pointers
if value == 0:
suffix = " (null pointer)"
elif not value.is_readable():
suffix = " (unreadable pointer)"
else:
suffix = ""
return f"{hex(value)}{suffix}"
elif isinstance(value, objects.PrimitiveObject):
return repr(value)
elif isinstance(value, objects.Array):
return repr([self._display_value(val) for val in value])
else:
return hex(value.vol.offset)
else:
# non volobject
if value is None:
return "N/A"
else:
return value
except exceptions.InvalidAddressException:
return "-"
# if value causes an InvalidAddressException like BaseAbsentValue then display N/A
return "N/A"
def generate_treegrid(
self, plugin: Type[interfaces.plugins.PluginInterface], **kwargs