GNOME Bugzilla – Bug 749696
Segfault with Gom
Last modified: 2015-07-06 07:49:24 UTC
I'm trying to use Gom from a Python script. The process dies with the following output: ** (process:5554): CRITICAL **: Unsupported type GType ** Gom:ERROR:gom/gom-command-builder.c:418:gom_command_builder_build_create: assertion failed: (primary_pspec) Abandon (core dumped) See attachments for more details.
Created attachment 303782 [details] A simple example using Gom in C This is a simple example showing how to use Gom in C. Compile it as follows: $ gcc -o test-gom -g \ $(pkg-config --cflags gom-1.0) \ $(pkg-config --libs gom-1.0) \ test-gom.c When running it, it prints: $ ./test-gom Item: id=1, name='item1' This is the reference, what I'd like to try and reproduce with Python.
Created attachment 303783 [details] My attempt at using Gom in Python I'm trying to reproduce the previously-attached C example in Python. When running it, it fails: $ python test-gom.py ** (process:5554): CRITICAL **: Unsupported type GType ** Gom:ERROR:gom/gom-command-builder.c:418:gom_command_builder_build_create: assertion failed: (primary_pspec) Abandon (core dumped) The error in Gom is triggered by line 24 of the Python script: repository.automatic_migrate_sync(1, [ItemResource.__gtype__]) Compare with how this looks in C: GList *object_types; object_types = g_list_prepend (NULL, GINT_TO_POINTER (ITEM_TYPE_RESOURCE)); ret = gom_repository_automatic_migrate_sync (repository, 1, object_types, &error); So in C I'm passing a GList with a single GType item, and in Python a list with a single GType item, which I'd expect to work.
After some discussion on IRC: <lazka> bochecha_, had a quick look. it's a pygobject bug <lazka> 1. gtype in glist support is missing 2. error handling code is missing resulting in garbage passed to gom
Created attachment 306846 [details] [review] Handle gtype marshalling
Created attachment 306847 [details] My attempt at using Gom in Python A Python script that actually works. After applying the patch I submitted earlier, the script I had originally submitted still had a few issues. This new version actually works, provided: 1. the patch for this bug is applied 2. this patch is applied to gom: https://bugzilla.gnome.org/show_bug.cgi?id=751977
Created attachment 306849 [details] [review] tests: add a test for test_glist_gtype_container_in() This (optionally) depends on https://bugzilla.gnome.org/show_bug.cgi?id=751978 in gobject-introspection
Review of attachment 306846 [details] [review]: Looks good, thanks.
Review of attachment 306849 [details] [review]: Thanks for adding tests.
Attachment 306846 [details] pushed as f69ce9f - Handle gtype marshalling