GNOME Bugzilla – Bug 684928
Cannot create GVariant with empty array of tuples
Last modified: 2012-09-27 06:21:23 UTC
Works fine: $ python3 -c "from gi.repository import GLib; print(GLib.Variant('(sa(ss))', ('hello', [('a', 'b')])))" ('hello', [('a', 'b')]) This doesn't, it either crashes with a segfault or an error: $ python3 -c "from gi.repository import GLib; print(GLib.Variant('(sa(ss))', ('hello', [])))" ** GLib:ERROR:/build/buildd/glib2.0-2.33.14/./glib/gvarianttypeinfo.c:789:g_variant_type_info_get: assertion failed (0 <= index): (0 <= -98) Aborted $ python3 -c "from gi.repository import GLib; print(GLib.Variant('(sa(ss))', ('hello', [])))" /usr/lib/python3/dist-packages/gi/types.py:47: Warning: g_variant_builder_end: assertion `!GVSB(builder)->uniform_item_types || GVSB(builder)->prev_item_type != NULL || g_variant_type_is_definite (GVSB(builder)->type)' failed return info.invoke(*args, **kwargs) Traceback (most recent call last):
+ Trace 230916
(v, rest_format, _) = creator._create(format_string, [value])
return self._create_tuple(format, args)
builder.add_value(v)
return info.invoke(*args, **kwargs)
With Python 2 it always throws the exception for me.
This is an even simpler case: $ python3 -c "from gi.repository import GLib; print(GLib.Variant('a(ii)', []))" gi/types.py:47: Warning: g_variant_builder_end: assertion `!GVSB(builder)->uniform_item_types || GVSB(builder)->prev_item_type != NULL || g_variant_type_is_definite (GVSB(builder)->type)' failed return info.invoke(*args, **kwargs) Traceback (most recent call last):
+ Trace 230917
raise TypeError('invalid remaining format string: "%s"' % rest_format)
Fixed with a bunch of tests in http://git.gnome.org/browse/pygobject/commit/?id=bfd9c8fac1ea240b29fbcd4185dc1702539c1e96