introspection: format property values with g_variant_print()

The main case where this helps is byte strings. GVariant has a special
case for values of type 'ay' which end with a NUL byte and otherwise
contain only printable ASCII characters: it prints them in the form
b'asciistring'. UDisks and Flatpak (among others) use bytestrings of
this form extensively for file paths, which are not guaranteed to be
UTF-8 so cannot be represented as D-Bus type 's'.

This does have the downside that b'foo' is also valid Python but means
something different:

In [2]: GLib.Variant('ay', b'abc')
Out[2]: GLib.Variant('ay', [0x61, 0x62, 0x63])

In [3]: GLib.Variant('ay', b'abc\0')
Out[3]: GLib.Variant('ay', b'abc')
parent d642a08d
Pipeline #37068 failed with stages
in 3 minutes and 27 seconds
......@@ -115,7 +115,7 @@ class AddressInfo():
-1,
None)
# update the object value so markup string is calculated correct
obj.value = result[0]
obj.value = result.get_child_value(0).get_child_value(0)
# set new markup string
model[iter_][0] = obj.markup_str
else:
......
# -*- coding: utf-8 -*-
from gi.repository import GObject, Gio
from gi.repository import GLib, GObject, Gio
from dfeet import dbus_utils
......@@ -87,7 +87,7 @@ class DBusProperty(DBusInterface):
args_signature_markup(sig),
args_name_markup(self.property_info.name), " / ".join(readwrite))
if self.value is not None:
s += " = %s" % (self.value,)
s += " = %s" % (GLib.markup_escape_text(self.value.print_(False)),)
return s
@property
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment