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 667194 - Fails to marshall NULL as an array return value
Fails to marshall NULL as an array return value
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2012-01-03 16:11 UTC by Paolo Borelli
Modified: 2012-01-03 16:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (1.73 KB, patch)
2012-01-03 16:12 UTC, Paolo Borelli
accepted-commit_now Details | Review
test (1.53 KB, patch)
2012-01-03 16:13 UTC, Paolo Borelli
accepted-commit_now Details | Review
test (921 bytes, patch)
2012-01-03 16:13 UTC, Paolo Borelli
accepted-commit_now Details | Review

Description Paolo Borelli 2012-01-03 16:11:27 UTC
The following testcase fails:

from gi.repository import Gtk, GdkPixbuf, Gdk, GtkSource
import os, sys

languageManager = GtkSource.LanguageManager()
languages = languageManager.get_language_ids()
goLanguage = languageManager.get_language('go')
print (goLanguage.get_style_ids()); # works
chdrLanguage = languageManager.get_language('chdr')
print (chdrLanguage.get_style_ids())  # causes "assertion failed: (arg->v_pointer

The assertion is due to the fact that get_style_ids returns a gchar** array but it may also return NULL when there are no ids. Pygobject does not handle that.

The follwing patches fix the issue and add a testcase that also reproduce the issue. However I am not sure if NULL should be handled as [] like in the patch or if it should be handled ad None.

Do we need a special annotation to say that NULL is a valid value?
Comment 1 Paolo Borelli 2012-01-03 16:12:04 UTC
Created attachment 204503 [details] [review]
patch
Comment 2 Paolo Borelli 2012-01-03 16:13:14 UTC
Created attachment 204504 [details] [review]
test

g-i part of the testcase
Comment 3 Paolo Borelli 2012-01-03 16:13:46 UTC
Created attachment 204505 [details] [review]
test
Comment 4 johnp 2012-01-03 16:34:38 UTC
Comment on attachment 204503 [details] [review]
patch

Looks good
Comment 5 johnp 2012-01-03 16:37:58 UTC
Comment on attachment 204504 [details] [review]
test

Feel free to commit this but make sure make check works for gobject-introspection.  I forget which test gir they check (either regress or gimarshalling) but they do a diff just to make sure something hasn't broken in the gi parser.
Comment 6 johnp 2012-01-03 16:39:20 UTC
BTW sequences should always return empty on NULL since GLib treats NULL as empty lists etc.
Comment 7 Paolo Borelli 2012-01-03 16:43:57 UTC
Thanks for the quick review, I pushed the patches (also the g-i part with Johan's blessing)