mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-21 10:14:41 +00:00
tools/tests: correct variant parsing
Seen in NM 1.42.6 where there is now a ipv4.dns-data key which have as signature: dbus.Array([dbus.String('a.b.c.d')], signature=dbus.Signature('s'), variant_level=1) This lead to the following exception: Cannot convert array element to type 's': Must be string, not Variant Moreover, the exception TypeError has no message field so it raised another expcetion which gave me trouble to find what's going on. Hence the addition of a log file from the previous commit Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com>
This commit is contained in:
parent
2f7a571759
commit
ae408fe4ab
|
@ -315,9 +315,9 @@ class Util:
|
|||
if isinstance(val, dbus.Array):
|
||||
try:
|
||||
if val.signature == "s":
|
||||
return GLib.Variant("as", [Util.variant_from_dbus(x) for x in val])
|
||||
return GLib.Variant("as", [str(x) for x in val])
|
||||
if val.signature == "b":
|
||||
return GLib.Variant("ab", [Util.variant_from_dbus(x) for x in val])
|
||||
return GLib.Variant("ab", [bool(x) for x in val])
|
||||
if val.signature == "y":
|
||||
return GLib.Variant("ay", [int(x) for x in val])
|
||||
if val.signature == "u":
|
||||
|
@ -349,8 +349,7 @@ class Util:
|
|||
)
|
||||
except Exception as e:
|
||||
raise Exception(
|
||||
"Cannot convert array element to type '%s': %s"
|
||||
% (val.signature, e.message)
|
||||
"Cannot convert array element to type '%s': %s" % (val.signature, e)
|
||||
)
|
||||
if isinstance(val, dbus.Dictionary):
|
||||
if val.signature == "ss":
|
||||
|
|
Loading…
Reference in a new issue