mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 01:20:07 +01: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
1 changed files with 3 additions and 4 deletions
|
|
@ -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…
Add table
Reference in a new issue