After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 684928 - Cannot create GVariant with empty array of tuples
Cannot create GVariant with empty array of tuples
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: introspection
Git master
Other Linux
: Normal normal
: ---
Assigned To: Martin Pitt
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2012-09-27 04:43 UTC by Martin Pitt
Modified: 2012-09-27 06:21 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Martin Pitt 2012-09-27 04:43:03 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):
  • File "<string>", line 1 in <module>
  • File "/usr/lib/python3/dist-packages/gi/overrides/GLib.py", line 169 in __new__
    (v, rest_format, _) = creator._create(format_string, [value])
  • File "/usr/lib/python3/dist-packages/gi/overrides/GLib.py", line 74 in _create
    return self._create_tuple(format, args)
  • File "/usr/lib/python3/dist-packages/gi/overrides/GLib.py", line 98 in _create_tuple
    builder.add_value(v)
  • File "/usr/lib/python3/dist-packages/gi/types.py", line 47 in function
    return info.invoke(*args, **kwargs)
TypeError: Argument 1 does not allow None as a value

Comment 1 Martin Pitt 2012-09-27 04:44:08 UTC
With Python 2 it always throws the exception for me.
Comment 2 Martin Pitt 2012-09-27 05:05:44 UTC
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):
  • File "<string>", line 1 in <module>
  • File "gi/overrides/GLib.py", line 171 in __new__
    raise TypeError('invalid remaining format string: "%s"' % rest_format)

Comment 3 Martin Pitt 2012-09-27 06:21:23 UTC
Fixed with a bunch of tests in

http://git.gnome.org/browse/pygobject/commit/?id=bfd9c8fac1ea240b29fbcd4185dc1702539c1e96